jqGrid 4.13.6-pre - free jqGrid
I am using navGrid and inline editing and am having trouble with formatting validation messages sent back from the server. The validation messages appear fine when they come back from an inline edit, but they do not look fine when on the Add/Edit form accessed from the grid navigation.
I read a lot about the errorTextFormat event and it seems to do exactly what I want, but I can't seem to figure out how to access it when the form is opened from the grid nav. I'm sure there's a simple way to configure it, but I have not been able to figure it out.
$(function() {
var lastSel = 0;
$("#Grid")
.jqGrid({
url: '/url/to/griddata',
datatype: 'json',
mtype: 'POST',
colNames: ['Id', 'Name'],
colModel: [
{ name: 'Id', hidden: false, search: true, width: 150, align: 'center', sortable: true, editable: false, formatter: null, edittype: 'text' },
{ name: 'Name', hidden: false, search: true, width: 150, align: 'center', sortable: true, editable: true, formatter: null, edittype: 'text', editoptions: { maxlength: 256, value: null, required: true } }],
pager: '#GridPager',
prmNames: {
page: 'PageNumber',
rows: 'PageSize',
sort: 'SortColumn',
order: 'SortOrder',
search: 'Search',
nd: 'nd',
npage: 'null'
},
rowNum: 60,
rowList: [
15,
30,
60,
120
],
sortname: "Name",
sortorder: "asc",
viewrecords: true,
hidegrid: false,
gridview: true,
caption: '',
width: 980,
height: 100,
editurl: '/my/edit/url',
edit: {
errorTextFormat: function (data) {
alert('fired');
console.log(data);
return "error here";
}
},
jsonReader: {
total: 'TotalPages',
page: 'CurrentPage',
records: 'TotalRecords',
root: 'Rows',
id: 'Id',
repeatitems: false
},
onSelectRow: function(id) {
if (id && id !== lastSel) {
jQuery('#Grid').restoreRow(lastSel);
lastSel = id;
}
$('#Grid').jqGrid('editRow', id,
{
keys: true
});
}
});
$("#Grid").filterToolbar({ autosearch: true, searchOnEnter: false });
$("#Grid").navGrid('#GridPager', {
del: false, search: false, editerrorTextFormat: function (data) {
alert('fired');
console.log(data);
return "error here";
}
});
Here is the markup.