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

Loading new data into DataSource breaks Angular data bindings

1 Answer 41 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 19 Jan 2016, 04:22 AM

I created a demo here: 

http://dojo.telerik.com/@cglendenin/aJuLe/3

When you first run it, if you click in the Category column of the grid, you get a dropdown list to change the category value. If you choose a different value in the first row, you can see it reflected immediately in the text above the grid. That works via AngularJS's standard data binding: `First product's category: {{ products[0].Category }}`

If you click the "Change Data" button, it runs a function that calls `dataSource.data([/* different array with new data... */])`, which changes the data in the grid. That works as expected. However, after this point, the dropdown list can no longer change the data. I assume that is because, when the dropdown list is initialized, it captures a reference to the original grid data, and calling dataSource.data([...]) makes the DataSource hold a reference to a new object?

Is there a workaround for this problem? Thanks!

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 21 Jan 2016, 08:25 AM

Hello Chad,

 

You must change the products reference in the $scope too when changing DataSource data.

 

$scope.products = newProducts;

 

Updated example - http://dojo.telerik.com/@rusev/aDIBI

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Chad
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or