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

RadGrid Insert/Update Mode Changes on Cancel

4 Answers 272 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 24 Mar 2015, 07:04 PM
Hi I have a radgrid in batch edit mode. I've created a javascript function that is fired OnCommand to do client side validation as described here: http://www.telerik.com/forums/batch-editing---row-validation. When I open a new row for insert, put in an incorrect value and hit save, the javascript fires and set_cancel is set to true.

The issue is that after the cancel, the grid now thinks this new row is an update instead of an insert. Once the user changes the flagged cells and hits save again, the validation passes and my C# RadGrid2_UpdateCommand is hit, with a null NewValues Hashtable and an empty OldValues Hashtable.

I'm using AutomaticInsert,Update,Delete on the grid. Should the grid not retain the insert state after cancel? If not how can I handle this?

4 Answers, 1 is accepted

Sort by
0
Nick
Top achievements
Rank 1
answered on 24 Mar 2015, 10:41 PM
I've found a similar issue in this post: http://betas.telerik.com/forums/radgrid-batcheditcommand---release-q3-2014---problem-to-get-data-of-newly-added-row

But I am not calling _extractChangesString, will this same insert to update change happen if I access any private (_) variable or method?
0
Konstantin Dikov
Telerik team
answered on 27 Mar 2015, 01:12 PM
Hello Nick,

It seems that the fix for the initial issue (with _extractChangesString method) is breaking the simple scenario, where you cancel the saving with args.set_cancel(true).

I will log this in our system, so our developers could fix this bug in one of our next releases. For the time being, you could use the following workaround, which works correctly with the example from the other forum post that you are referring to:
if (validationFails) {                         
    args.set_cancel(true);
    batchManager._changes[masterTable.get_id()]["alreadyInsertedIndexes"] = null;
}

Please excuse us for any inconvenience caused by this.


Regards,
Konstantin Dikov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Vandana
Top achievements
Rank 1
answered on 22 Dec 2015, 05:47 AM

Hi,

 I'm having exactly same issue. I didn't understand your solution. I tried this:

if (validationFails) {                         
    args.set_cancel(true);
    batchManager._changes[masterTable.get_id()][-1] = null;

}

Where -1 is the index it generates for the newly added rows. Is it all we need to do, or anything else needs to be done as well?

Because after doing this I'm still getting error.

0
Konstantin Dikov
Telerik team
answered on 24 Dec 2015, 12:08 PM
Hello Vandana,

Actually, the "alreadyInsertedIndexes" is a property in the _changes object, so you need to use the exact same code (with the name of that property) and clear the array with the inserted items indexes:
batchManager._changes[masterTable.get_id()]["alreadyInsertedIndexes"] = null;

Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Nick
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Vandana
Top achievements
Rank 1
Share this question
or