I need to do some server side validation of data that is being updated on a large grid and wanted to give the user an idea of where any validation errors occurred in the grid. Ideally it would be by highlighting the row/cell and having a mouse over or other error message associated.
What I have done so far is:
Controller:
JavaScript grid error handler
It seems like the code is working, but it doesn't seem to stick around until the end and if I use the IE developer tools it doesn't show the new class or have the mouseover. What am I missing?
Thanks!
What I have done so far is:
Controller:
ModelState.AddModelError(Item.Id, "this value is outside of the valid range");
01.
function
error_handler(e) {
02.
var
data = e.sender._data;
03.
if
(e.errors) {
04.
$.each(e.errors,
function
(key, value) {
05.
highlightError(data, key, value);
06.
});
07.
}
08.
}
09.
10.
function
highlightError(data, key, value) {
11.
var
grid = GetGrid(
"grid"
);
12.
for
(
var
i = 0; i < data.length; i++) {
13.
var
row = data[i];
14.
15.
if
(row.id == key) {
16.
var
hasError = $(
'[data-uid="'
+ row.uid +
'"]'
);
17.
hasError.addClass(
'kendo-error-row'
);
//this seems to be working, but it doesn't survive the whole process.
18.
hasError[0].mouseover =
function
() { alert(errors[error].value); };
19.
}
20.
}
21.
}
Thanks!