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

How to cancel the removeRow action when server side error occurs?

3 Answers 512 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wicky
Top achievements
Rank 1
Wicky asked on 17 Feb 2013, 09:09 AM
Hello,

I tried to manually remove a row from grid, something like: 

grid.dataSource.remove(dataItem);
grid.dataSource.sync();
grid.dataSource.read() 

If the removal is successful, everything seems ok.
If server side error occurs (throw exception, which could be caught in client error event), the grid looks OK after read(), but when I try to delete the row again, same custom error will be triggered twice, and more if click delete button more times.
I guess the custom errors or destroyed rows are accumulated. I have to reload the page to clear the errors.

What I want to achieve is:
1) When click a custom Delete button,  delete current selected row
2) If deleting is successful, hide the row (or refresh the grid)
3) If deleting is not successful, show error and restore the row (or refresh the grid)

Please help to advice how to refresh the grid and clear destroyed rows/custom errors completed after server side removal error?

Thanks
Wicky

3 Answers, 1 is accepted

Sort by
0
Wicky
Top achievements
Rank 1
answered on 18 Feb 2013, 02:44 AM
Hello,

I found the "error not cleared" issue existed not only in removal, also in new or edit operation.

Steps to re-produce the issue:
1) create a simple table with Id and Code fields, the Id is auto-generated integer identity, the Code has unique key in database
2) Add New Record in Grid, input 11 and save, record saved OK and editor closed
3) Add New Record in Grid, input 11 and save, unique index error (11) will occur and be caught in client error event, editor is still opened;  now amend the value to 22 and save, unique index error (11) still occur and be caught in client error event

Regards
Wicky

0
Wicky
Top achievements
Rank 1
answered on 18 Feb 2013, 03:30 AM
Hello,

After further debugging, I found it was not "error not cleared", it's "entity not cleared".

For example,
when input first "11", there is one post to server, the record saved OK; 
when input second "22", there are two post to server, one for "11" and one for "22", and "22" actually saved OK and "11" error;
when input third "33", there are three post to server, for "11","22","33", and "33" actually saved OK and "11","22" error ...

It seems the all new records in previous operations are posted to server when saving current new record.
I tried online demo, there is no unique checking so duplicated records could be added.

Do I miss something? Is there anything need to call after save action?
Or Kendo Grid just doesn't handle the status properly?

Thanks
Wicky
0
Accepted
Alexander Valchev
Telerik team
answered on 19 Feb 2013, 05:12 PM
Hi Wicky,

Problems related to duplicated records are usually connected with the IDs. You can find more information on the subject in this forum thread.

In order to cancel the removeRow action, you may use the cancelChanges method. It will cancel all the pending changes - deleted rows are restored, inserted rows are removed.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Wicky
Top achievements
Rank 1
Answers by
Wicky
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or