This is a migrated thread and some comments may be shown as answers.

Kendo angular grid template bindings - dataItem is a copy of the original object, changes not reflected

0 Answers 88 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
squarewave
Top achievements
Rank 1
squarewave asked on 30 Nov 2017, 02:00 AM

using TreeList grid in Kendo UI v2017.3.1026 with AngularJS v1.6.1.

when i define my bindings in a template like this:

    `<input ng-if="vm.foo(dataItem) ng-change="vm.priceChanged(dataItem)" ng-model="dataItem.currentPrice.value" />`

it sort of works. the events do fire but I noticed that the underlying object is no longer synchronized with the rest of the page.

dataItem appears to be a copy of the original object with additional properties, and the original [item in the collection the grid is bound to] does not get updated.

this is of course a problem since the page has more than the grid and any changes in the grid need to be propagated to the original objects in the controller.

 

I could manually find / synchronize the dataItem passed to the ng-change event with the original object in angular controller collection, but hoping there is a better way

second issue is that modifying the kendo version of dataItem OR the original, does not immediately show up in the grid. seems like it needs to be manually refreshed? I am using k-rebind technique:

    <div id="grid" kendo-tree-list k-options="vm.treeListOptions" k-rebind="vm.dataVersion"></div>

and in my event I call this.dataVersion++ after updating underlying collection, but this does not refresh the grid.

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
squarewave
Top achievements
Rank 1
Share this question
or