How do I send a custom error message to the client a Telerik MVC Grid Ajax Insert/Update/Delete?

StackOverflow https://stackoverflow.com/questions/4127684

  •  29-09-2019
  •  | 
  •  

Question

I am working with Ajax Editing within a Telerik Grid extension. I would like to handle errors/exceptions on Insert/Update/Delete and display a user friendly message in the message box that is displayed back to the client, instead of the default message of "Error! The requested URL returned 500 - Internal Server Error" or the like.

Is there a way to tell the grid to display a custom text message?

Was it helpful?

Solution

Someone customized the alert here: http://www.telerik.com/community/forums/aspnet-mvc/grid/how-to-return-error-information-to-grid-in-ajax-editing-mode.aspx, but I'm still searching for a way to actually update the grid itself...

There's a little hope in the client-side grid's noRecordsTemplate property, but we still need a way to clear the grid of any records that may have already been there.

Edit:

Found it: To clear the grid, and set your message, do the following:

var grid = $('#Grid').data('tGrid');
grid.total = 0;
grid.dataBind(Array());
$('#Grid').find('.t-no-data td').text('My Custom Error Message');

Of course, you can figure out on your own how to combine the my example and the example from the link above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top