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

Keep modified fields in batch edit grid after save changes failed

4 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Flavien B.
Top achievements
Rank 1
Flavien B. asked on 03 Nov 2014, 02:58 PM
Hi,
when I update some fields in my grid in batch edit mode and click on "save changes" to store my updates in db, I sometimes have server side errors (more complex server-side validation, database access issue, ...).
In that case, I display the errors from the server, but my radgrid is completely re-binded and I lost all my updates. (that can be massive updates...)
I can't find how to keep my updates for the user to change its erroneous fields.
Am I missing something ?
Thanks in advance

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 06 Nov 2014, 08:42 AM
Hello Flavien,

Since Batch Editing is an entirely client-side oriented edit mode, all the changes made on the client will be lost on postback and there is no built-in functionality that will allow you to overcome this behavior. With Batch Editing, all validations that you need to perform on the user input needs to be performed on client-side. If you need complex server-side validation you should consider switching to another edit mode.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Flavien B.
Top achievements
Rank 1
answered on 06 Nov 2014, 09:13 AM
Ho please Telerik, don't give up so easily !
Batch Editing is not entirely client-side oriented since updates are reported server-side by the BatchEditCommand. (Ok, it's pretty messy as we have to find updated values ourself even though they are known client-side)
In short, waiting for your reply, I had time to experiment. And it turns out that making a backup of the changes via the GlobalBatchEdit command and reapply them once the grid reload via the grid.get_batchEditingManager().changeCellValue(cell, updatedValue) command works almost perfectly, except for two bug, which are that the GridDropDownColumn needs the value extracted from ListTextField instead of the one extracted from ListValueField, and we have to set a delay between the GridCreated event and the reapply of the changes.
All that in less that 30 lines of javascript.

Regards,
Flavien B.
0
Konstantin Dikov
Telerik team
answered on 11 Nov 2014, 08:37 AM
Hello Flavien,

In my previous post I have said that there is no built-in functionality that could enable you to have such behavior. Yes, it could be possible to store all changes and apply them once the response ends, but you will have to ensure that there are no changes within the grid's data before and after the postback. Additionally, you can not store the changes by row indexes, because there are too many scenarios, where this will fail.

As for the GridCraeted event, indeed, the Batch Editing Manager will not be available at this point and it is better to handle the page's load event handler instead:
function pageLoad(){
        .....
}


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Flavien B.
Top achievements
Rank 1
answered on 14 Nov 2014, 08:35 AM
Hello Konstantin,
of course we have to ensure there are no changes, but it's not that hard. And to be able to index the rows, I agree that the use of DataKeys is mandatory.
About the PageLoad event, thanks for the tip !

Regards,
Flavien B.
Tags
Grid
Asked by
Flavien B.
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Flavien B.
Top achievements
Rank 1
Share this question
or