I dont know what's wrong with my coding?
colModel: [
{
key: true, hidden: true, name: 'Id', index: 'Id', editable: true
}, {
name: 'ProjectCode',
index: 'ProjectCode',
sorttype: "text",
edittype: "text",
editable: true,
editrules: {
required: true,
custom: true,
custom_func: function (value, colName) {
return validateDuplicateData(value, colName);
}
}
}
Here is validateDuplicateData function :
function validateDuplicateData(value, colName) {
var allRowsInGrid = $('#jqgrid').jqGrid('getRowData');
$.each(allRowsInGrid, function (k, v) {
if (v.ProjectCode == value) {
return [false, "Project code has been used. Please try using another code."];
}
});
}
why the result always shows below :
MessageBox : "Custom function should return array!"
Please advice... Thank you..
The function never returns true with array. It should return true at the end of function if, after looping, no duplicate data was found.