Hello,
I have a grid with detail template, and a button in detail section will change one cell value of its master row.
The question is that, after cell value is changed (datasource.set), this grid is rebind, original detail of this row is gone, and this row is unselected. This isn't what I want.
Is there a way to avoid rebinding this grid, I just want to change a cell value without rebind, and keep this detail section, this selected row etc..5 Answers, 1 is accepted
Hello Lihong,
The main idea of rebinding and repainting the Kendo UI Grid after modifying a model field value using the set method is to update the cell value (display the new value in the cell element). Otherwise the table cell will display the old value.
The only way to achieve such behavior without repainting the Kendo UI Grid is to find the table cell DOM element and change its value.
Regards,
Boyan Dimitrov
Telerik
In your method, will be value in data source changed?
My purpose is that, without rebind and repaint grid, change a field value (datasource.set), then related cell should be changed too.
This is very useful in fact.
Is there a way?
Hello Lihong,
When the grid is rendered it takes the model field value and display it in the cell. This is why after modifying the model field using the set method, the grid is rendered again and the new value will be properly shown.
Regards,
Boyan Dimitrov
Telerik
I'm really disappointed with your grid.
I can't really understand, why you repaint the whole grid when a field value is changed?
I just want to know, whether there is a way, a cell value synchronizes with its field value without repaint?
If no, we may consider abandon the use of this grid.
Hello Lihong,
I am afraid that when a model field value is changed using the set method, the Kendo UI Grid will be redrawn and rebound. This is caused due to the fact that when change event of the Kendo UI DataSource is fired the Grid is rebound. The change event is fired when a value of the model is updated/delete or a new item is created. This is how the Kendo UI Grid is designed to work and how it synchronizes changes made to the model with the UI.
My suggestion would be to take a look at the Persist expanded rows after refresh example that demonstrates how to persist expanded rows after refresh. The parent grid will be refreshed, but the lastly expanded row will be expanded again in order to retain the expanded state.
Another possible solution is to use two separate Kendo UI Grid widgets on the page. The second one to be populated with data when a selection from the first (master grid) is made. Considering the fact that both grids are completely separate even if the master grid is rebound and redrawn the child grid will remain same and will not be affected. In order to achieve this functionality you can use the change event of the master grid and populates the second grid based on the selected date item.
Regards,
Boyan Dimitrov
Telerik