jQuery + jqgrid postData覆盖默认值 [英] jQuery + jqgrid postData overriding default values

查看:236
本文介绍了jQuery + jqgrid postData覆盖默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个网格,我像这样设置了一些默认值...

so I have grid which I set some defaults on like so...

defaults: {
    datatype: "json",
    mtype: "POST",
    autowidth: true,
    height: '100%',
    viewrecords: true,
    loadonce: false,
    rowNum: 100,
    rowList: [15,30,50,100,200,500]
},

然后,根据要加载的页面,我设置了colModel,然后设置了其他一些类似的东西:

then depending on the page being loaded I set the colModel and then finally few other things like follows:

var fields = $(":input").serialize(); //into post data..

jQuery('#'+$Global.trxGrid.gridId)
    .setGridParam({
        url : page,
        postData : fields,
        loadError: function(xhr,st,err) {
            $('#searchErrorText').text('Please try again later.');
            $('#searchErrorDialog').dialog('open');
        },
        ajaxGridOptions: {
            timeout: 150000
        }
     }
 );

但是当我检查postData时,prmName不存在(_search = false& nd = 1324619663709& rows = 100& page = 1& sidx =& sord = asc)等.如果我在上面注释了postData方法,然后它们出现. postData会覆盖所有内容吗?如果是这样,我想我需要追加反对以覆盖,但是我找不到任何干净的方法来做到这一点.有人可以提出解决方案,还是我做错了什么?

but when I inspect the postData the prmNames are not there (_search=false&nd=1324619663709&rows=100&page=1&sidx=&sord=asc) etc. If I comment out the postData in the above method then they appear. Does the postData override everything? If so I guess I need to append as oppose to override but I can't find any clean way to do this. Can someone suggest a solution or am I doing something wrong?

推荐答案

您必须在选项中添加一个名为serializeGridData的附加选项,请参见

you have to add a extra option to your options called serializeGridData see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:events

所以您应该执行以下操作:

so you should do something like this:

$('#grid').jqGrid({
    url: 'url',
    ....
    serializeGridData: function(postData) {
      var newPostData = $.extend(postData, {
        extraParam: 'EXTRA-PARAM-VALUE'
      });

      // newPostData now is (_search=false&nd=1324619663709&rows=100&page=1&sidx=&sord=asc&extraParam=EXTRA-PARAM-VALUE)
      return $.param(newPostData);
    }
});

这篇关于jQuery + jqgrid postData覆盖默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆