Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery jqgrid自定义函数验证现有行_Jquery_Asp.net Mvc_Jqgrid_Custom Function - Fatal编程技术网

Jquery jqgrid自定义函数验证现有行

Jquery jqgrid自定义函数验证现有行,jquery,asp.net-mvc,jqgrid,custom-function,Jquery,Asp.net Mvc,Jqgrid,Custom Function,我不知道我的编码有什么问题 colModel: [ { key: true, hidden: true, name: 'Id', index: 'Id', editable: true }, { name: 'ProjectCode', index: 'ProjectCode',

我不知道我的编码有什么问题

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);
                        }
                    }
                }
下面是validateDuplicateData函数:

 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."];
            }
        });
    }
为什么结果总是如下所示:

MessageBox:“自定义函数应返回数组!”

请建议。。。
谢谢。

函数在数组中永远不会返回true。如果循环后未发现重复数据,则在函数结束时应返回true。

应将当前行中的值排除在测试之外。你能详细介绍一下你的工作吗?您使用哪种编辑模式和数据类型?您使用的jqGrid的哪个版本以及jqGrid(、商业版或版本中的旧jqGrid)的哪个分支详细描述了
custom
回调的选项。有关更多详细信息,请参阅。