Is there a way to get the row number that caused the error when a server side validation failed
for example in the function grid_error(e) in this example http://docs.telerik.com/kendo -ui/aspnet-mvc/helpers/grid/ajax-editing
Thanks,
Annie
1 Answer, 1 is accepted
0
Daniel
Telerik team
answered on 10 Nov 2014, 01:17 PM
Hello Annie,
By default there isn't any information for the model included in the errors returned from the server. It is possible to get the row by searching for the grid row that is currently in edit mode:
function grid_error(e) {
if (e.errors) {
var grid = $("#grid").data("kendoGrid");
var row = grid.tbody.children(".k-grid-edit-row");
...
}
}
Another option would be to override the Errors property in the DataSourceResult so that it includes the model or model Id:
var result = new[] { product }.ToDataSourceResult(request, ModelState);
if (result.Errors != null)
{
result.Errors = new
{
Id = product.ProductID,
errors = result.Errors
};
}
return Json(result);
and then use the Id to find the row.
Regards,
Daniel
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.