【发布时间】:2018-03-30 09:26:01
【问题描述】:
我有一个剑道网格:
<kendo-grid
[data]="gridData"
[pageSize]="state.take"
[skip]="state.skip"
[sort]="state.sort"
[filter]="state.filter"
[sortable]="true"
[pageable]="true"
[filterable]="true"
[kendoGridSelectBy]="'guid'"
[selectable]="true"
[selectedKeys]="selectionCustomer"
(dataStateChange)="dataStateChange($event)"
>
<kendo-grid-checkbox-column></kendo-grid-checkbox-column>
<kendo-grid-column field="name" title="Name"></kendo-grid-column>
<kendo-grid-column field="prename" title="Prename"></kendo-grid-column>
<kendo-grid-column field="companyName" title="CompnayName"></kendo-grid-column>
<kendo-grid-column field="number" title="number"></kendo-grid-column>
<kendo-grid-column field="fullname" title="Fullname"></kendo-grid-column>
</kendo-grid>`
组件从 API 加载数据(作为数组,因为没有可用的 Odata)
export class CustomerKendoComponent implements OnInit {
private state: State = {
skip: 0,
take: 10,
};
private customers: Customer[] = [];
private gridData: GridDataResult = null;
private selectionCustomer: number[] = [];
constructor(
private customerApi: CustomerApi,
private ref: ChangeDetectorRef,
) { }
ngOnInit() {
this.customerApi.apiCustomerGet().subscribe(response => {
this.customers = response.customers;
this.gridData = process(this.customers, this.state);
this.ref.detectChanges();
})
}
printSelection() {
console.log(this.selectionCustomer);
}
}
如果我点击一行,什么都不会发生。 没有错误,没有选择。
为了找到问题,我在 UI 中添加了一个按钮,用于打印选定的行 guid。
<button md-raised-button color="primary" (click)="printSelection()">print</button>
如果我按下按钮,控制台会打印正确的 GUID,并且该行会被高亮显示!但前提是我按下按钮。
我在 https://www.telerik.com/kendo-angular-ui/components/grid/selection/ 的文档中看不到更多内容 我也尝试过使用 selectableSetting,但没有任何变化。
为什么我的 Grid 选择不会触发“UI 刷新”?
版本
"@progress/kendo-angular-grid": "^1.4.2",
"@angular/core": "~4.3.1",
抱歉重用了 angular2 标签,我不允许为 kendo-ui-angular4 创建新标签
【问题讨论】:
标签: angular telerik kendo-ui-angular2