Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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
postData未发送到jqgrid中的服务器_Jqgrid - Fatal编程技术网

postData未发送到jqgrid中的服务器

postData未发送到jqgrid中的服务器,jqgrid,Jqgrid,为什么从不将PostData值发送到服务器?如果我使用一个fixwed值postData:{test:“3”}它可以工作,但在使用函数时,不会向服务器传递任何内容。。。。。 Firebug不会显示测试变量的任何痕迹 $("#tblgrid").jqGrid({ datatype: 'json', ajaxGridOptions: { contentType: "application/json" }, ajaxRowOpti

为什么从不将PostData值发送到服务器?如果我使用一个fixwed值postData:{test:“3”}它可以工作,但在使用函数时,不会向服务器传递任何内容。。。。。 Firebug不会显示测试变量的任何痕迹

$("#tblgrid").jqGrid({
            datatype: 'json',
            ajaxGridOptions: { contentType: "application/json" },
            ajaxRowOptions: { contentType: "application/json", type: "POST" }, //row inline editing
            serializeGridData: function(postData) { return JSON.stringify(postData); },
            jsonReader: {
                repeatitems: false,
                id: "0",
                cell: "",
                root: function(obj) { return obj.d.rows; },
                page: function(obj) { return obj.d.page; },
                total: function(obj) { return obj.d.total; },
                records: function(obj) { return obj.d.records; }
            },
            url: 'orthofixServices.asmx/GetProductList',
            postData: { test: function() { return $("#tid").val(); } },
            datatype: 'json',
            colNames: ['id', 'Product Description', 'Commission Rate'],
            colModel: [
            { name: 'id', width: 50 },
            { name: 'description', index: 'desc', width: 380, editable: true },
            { name: 'commissionrate', index: 'com', width: 120, editable: true, unformat: percentUnFormatter, formatter: percentFormatter, editrules: { number: true} }
            ],
            serializeRowData: function(data) {

                var params = new Object();
                params.id = 0;
                params.prdid = 4;
                params.description = data.description;
                params.commissionrate = data.commissionrate;
                var result = JSON.stringify({ 'passformvalue': params, 'oper': data.oper, 'id': data.id });
                return result;
            },
            mtype: "POST",

            rowNum: 4,
            width: 500,
            height: 80,
            pager: '#pager',
            editurl: "orthofixServices.asmx/ModifyProductList"
        });
        $("#tblgrid").jqGrid('navGrid', '#pager', { add: false, edit: false, del: true }, {
        //edit options

    }, {
    //add options     

}, {
//delete options
}))

该字段表示要发送到服务器的数据:

此数组直接传递到url。这是关联数组,可以这样使用:
{name1:value1…}

代码的问题是您试图将函数(代码)传递给服务器。相反,您需要直接传递数据:

postData: { test: $("#tid").val() }

您需要实际执行已将postData设置为的函数

将其添加到您的数据中:

                   for (propertyName in data) {
                        if (data.hasOwnProperty(propertyName)) {
                            propertyValue = data[propertyName];
                            if ($.isFunction(propertyValue)) {
                                dataToSend[propertyName] = propertyValue();
                            } else {
                                dataToSend[propertyName] = propertyValue;
                            }
                        }
                    }

我试图做这里解释的事情:。所以postData似乎接受了一个函数,该函数将在每次重新加载网格时动态更新