当服务调用选择新数据时,kendo angular 2 grid cusomized数据绑定问题将不会绑定

时间:2017-12-19 14:11:50

标签: asp.net-web-api kendo-grid kendo-ui-angular2

https://www.telerik.com/kendo-angular-ui/components/grid/columns/#toc-auto-generated-columns

Here Dynamically columns binding is missing:

The First time data binding correctly. The second time onwards it's not binding why?

this.gridData ---> is the Api response data

 this.gridView = {enter code here
          data: this.gridData,
          total: this.petService.pets.length
        };

1 个答案:

答案 0 :(得分:0)

你是什么意思"第二个tume开始"? Grid应该如何更新?

如果每次新数据到达时都会更新Grid绑定的对象,Grid将相应地使用最新数据重新渲染,例如:

ngOnInit() {
      this.interval = setInterval(() => {
        const rnd = Math.floor(Math.random()*sampleCustomers.length);
        this.gridData = sampleCustomers.slice(rnd, rnd + 10)
      }, 1000);
    }

EXAMPLE