我的代码: 自定义验证功能错误请帮助>>>>
自定义验证函数无法返回值,json函数仍然有效,但无法返回值
<script type="text/javascript">
$(document).ready(function () {
$.getJSON("/ChequeBookReceipt/getChequeType/", function (data) {
setupGrid(data.item);
});
function reload(result) {
$("#listChequeBook").trigger("reloadGrid");
}
});
function setupGrid(data) {
var success = false;
var message = 'success';
var item = data;
jQuery(document).ready(function () {
/*Begin Grid*/
$("#listChequeBook").jqGrid({
url: '/ChequeBookReceipt/GetChequeBookGrid/',
datatype: 'json',
mtype: 'GET',
data: $(this).serialize(),
colNames: ['Cheque Type', 'Book number', 'First Leaf Number', 'Last Leaf Number'],
colModel: [
{ name: 'chequeType', index: 'chequeType', editrules: { required: true }, width: 150, editable: true, sortable: false, sorttype: "text", edittype: "select", editoptions: { value: item }, formatter: "select", width: "200px" },
{ name: 'bookNumber', index: 'bookNumber',
editrules: { integer: true, required: true, custom: true,
custom_func: function (value, colname) {
$.ajaxSetup({ cache: false });
$.getJSON("/ChequeBookReceipt/IsUniqueBookNumber/", { value: value, colname: colname }, function (data) {
if (data != null) {
//alert(data.success + " - " + data.message);
return [data.success, data.message];
}
});
}
}, formoptions: { elmsuffix: ' *' }, sortable: false, width: 100, editable: true, sorttype: "text", width: "100px"
},
{ name: 'firstLeafNumber', index: 'firstLeafNumber', editrules: { integer: true, required: true }, formoptions: { elmsuffix: ' *' }, sortable: false, width: 100, editable: true, sorttype: "text", width: "100px" },
{ name: 'lastLeafNumber', index: 'lastLeafNumber', editrules: { integer: true, required: true}, sortable: false, width: 100, editable: true, sorttype: "text", width: "100px" }
],
rowNum: 10,
rowList: [10, 20, 30],
// loadonce: true,
ignoreCase: true,
autowidth: true,
sortname: 'bookNumber',
sortorder: "asc",
pager: jQuery('#pagerChequeBook'),
viewrecords: true,
caption: "Cheque Book",
editurl: "/ChequeBookReceipt/UpdateChequeBookGrid/",
// onSelectRow: function (id) {
// if (id && id !== "") {
// jQuery('#listChequeBook').editRow(id, true);
//
// }
// },
beforeRequest: function () {
$.getJSON("/ChequeBookReceipt/getChequeType/", function (data) {
item = data.item;
// setupGrid(data.item);
});
}
});
jQuery("#listChequeBook").jqGrid('navGrid', "#pagerChequeBook", { edit: false, add: false, del: true, search: false, refresh: false },
{ reloadAfterSubmit: true });
$("#listChequeBook").jqGrid('inlineNav', '#pagerChequeBook', { addParams: { addRowParams: {
"keys": true, "aftersavefunc": function () { var grid = $("#listChequeBook"); reloadgrid(grid); }
}
}, editParams: { "aftersavefunc": function () { var grid = $("#listChequeBook"); reloadgrid(grid); } }
});
function reloadgrid(grid) {
// grid.trigger("reloadGrid");
grid.setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid');
}
/*End Grid*/
});
}
</script>
自定义验证功能错误请帮助
请帮助