When you bind to a Kendo UI Grid with MVVM, databound will fire once and all is well. If you need to update that data after the fact, every time you change one piece of data on any viewmodel (or child viewmodel), the entire grid re-databinds. Thus, if you had some cell in the grid that is bound to a template and you have to change 2 or 3 properties on the viewmodel from some external ajax source, Databound will fire 2 or 3 times for each model that is changed, causing the entire viewable area to rebind. How can we update lots of data at once and only have databound fire once?
相关问题
- ObservableCollection in ViewModel is not updated w
- Is it possible to send a List<Object> in MVV
- How to make an element reference a StaticResource
- Get the selected items of a ListView (MVVM, Calibu
- How to include MaterialDesignXamlToolkit to WPF cl
相关文章
- Best way to implement MVVM bindings (View <-> V
- Using LiveData to set visibility of TextView
- app:visibleGone cannot resolve on android Databind
- Kendo Ui Dropdownlist Set Visible via Javascript
- WPF MVVM two-way updates
- Difference between Set() and RaisePropertyChanged(
- How to change view date dynamically (which is filt
- Kendo DropDownList Shows DataValueField Prior to D
How exactly you rebind the Grid? Basically if you change some of the models like this:
This way the Grid will be indeed bound two times because of the MVVM. The change event is triggered each time you call set.
However if you update the values like this:
The Grid wont react to the change and wont rebind re-read the values from the models you can force the Grid to do it through the refresh method.
It looks like the dataBinding event is where you can prevent a rebind on the grid.
Telerik Online Docs
I'm not sure if there is some way to temporarily tell the grid to stop listening to events and then at the end, re-sync once. If there is, please give that answer here! Otherwise, what I did instead is I didn't go through .set() for each item. Instead, I updated the data for all the rows by setting the data directly to the property. Then when I got to the very last row I was updating, I called .set() on the last property that needed to be updated. This will cause databound to fire only once and the entire grid will refresh itself with all the data that was changed. If you don't do it this way, then the more rows displayed on the page, the longer it takes to process. (It could take 20+ seconds before the user can do anything again.)