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

Kendo UI Grid DataSource bind to observable object property

2 Answers 386 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 1
Anton asked on 23 Apr 2020, 10:49 AM

Hello!

Is it possible to bind grid DataSource to observable object in a way where grid reacts on the changes in the observable object automatically (without triggering .read() method manually)?

There's is an example: http://dojo.telerik.com/IloJiROR

The question is: is it possible to set somehow a dataSource that will automatically react on changes in the model? I wanna change items in the array (in fact it's property of observable object) and see that my grid is changed automatically.

2 Answers, 1 is accepted

Sort by
0
Anton
Top achievements
Rank 1
answered on 23 Apr 2020, 12:37 PM

As a workaround I can subscribe to "change" event of observable object, but unfortunately I work with app where the only one model and it's more then 1300 lines, so it's not efficient subscribe to "change" event.

As I understand it's not possible to subscribe to "change" event of particular property of observable object?

0
Accepted
Tsvetomir
Telerik team
answered on 27 Apr 2020, 08:32 AM

Hi Anton,

I have investigated the provided code snippets and I have noticed that the Read option of the data source is configured to read from an object with a collection. Since there is no binding between the two, the only option to refresh the data would be to call the read() method of the data source. 

However, in such cases, it is recommended to utilize the MVVM pattern that would enable you to dynamically alternate the data source via the data() method. Check out the updated example here:

https://dojo.telerik.com/EvITegUD

I hope you find this helpful.

 

Regards,
Tsvetomir
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Data Source
Asked by
Anton
Top achievements
Rank 1
Answers by
Anton
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or