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

Need help on a grid problem after server validation

3 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chuen
Top achievements
Rank 1
Chuen asked on 27 May 2014, 06:59 PM
Hi,

I had spent a few days on debugging this problem on my Kendo Grid, but I couldn't figure out why my grid data in the grid is broken after the server returns a validation error.  I have deployed this sample to the cloud and was hoping that someone could help to take a look.

Here are my repro steps:

1. Go to this website in the cloud at http://mandala.cloudapp.net
2. Click "Add New Character" to add one new record.  Type anything on character and actor.  Put a bad Url such as "http://<>".
3. Click "Submit Changes" to save the changes
4. Server will validate the bad URL and return an error.  Dismiss the error dialog.
5. Now fix the bad URL and put in a good one.
6. Click "Submit Changes" again.  This time it won't work.

I spent hours to debug this.  Even the editing stays, I noticed the pending data in the datasource got erased after the validation.  I don't know if there is a bug on my side, but I could use some help here.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Chuen
Top achievements
Rank 1
answered on 29 May 2014, 12:19 AM
Let me clarify some more here.  After #4 (server validation error), the code did a grid.one to prevent data rebinding to the grid.  But to my surprise, my datasource also got a change event and it messed up my underlying data.  As a result, the grid cell we are still editing actually got messed up because the data in edit is no longer the same.

See for yourself on this URL: http://mandala.cloudapp.net

Any takers on this mystery?
0
Accepted
Petur Subev
Telerik team
answered on 29 May 2014, 03:43 PM
Hello Chuen,

The problem seems to be that you are using the schema.errors function not to specifying whether there is error or not, but instead you directly display the errors message to the user. Since you do not return anything inside the function, the response is actually considered successful and your model is updated with the response (which is wrong) and also you will see that the error event is not triggered at all.

Here is as example to simulate your case:

http://trykendoui.telerik.com/@pesho/ICuC

Edit a record press save and you will see it goes wrong and the error event is not triggered at all.

Inside the schema.errors function all you need to do is to return the error field that holds the error.

e.g.

schema: {
  errors: function (e) {
    if (e.Errors) {
      return e.Errors;
    }
  },

Then the error event will be triggered and you can inside of it attach the dataBinding handler that prevents the rebinding.

I hope this information reveals the mystery.

Kind Regards,
Petur Subev
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
Chuen
Top achievements
Rank 1
answered on 29 May 2014, 06:10 PM
Thank you very much for the reply.  Your suggestion fixed the problem.

I wish that I didn't spend as much time as I did on this issue.  I searched the web extensively, but I could hardly find many good examples of this kind.  Some sample code from the web use Razor, which is not as useful to me since I always like to step the code line by line to see what's going on.
Tags
Grid
Asked by
Chuen
Top achievements
Rank 1
Answers by
Chuen
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or