【问题标题】:jqgrid userData posting null on refreshjqgrid userData在刷新时发布null
【发布时间】:2010-11-22 22:49:56
【问题描述】:

我有一个 jqgrid 和一个表单。刷新网格时,我试图将表单的值发送到服务器端处理程序。为了进行测试,我只在表单中使用了一个变量。 Firebug 显示 jqgrid 正在传递字段名称,但无论选择什么,该值始终为 null。

根据 jqgrid 文档,我应该使用 postData 变量来处理这个问题:

postData: {POINIT : jQuery('#POINIT').val()}

我还对此进行了测试,以确保调用 jQuery 来获取值适用于页面的其他部分——只是在刷新网格时不起作用。

以下是相关代码:

jQuery(document).ready(funcion(){ 
  jQuery("#list").jqGrid({
    url:'poquery.php',  
    datatype: 'json',
    mtype: 'POST',
    colNames:['PO Number ','Date','Vendor','Dept','Buyer','Terms'],
    colModel :[ 
      {name:'PONUMB', index:'PONUMB', width:65}, 
      {name:'PODATE', index:'PODATE', width:70},
      {name:'POVEND', index:'POVEND', width:70},
      {name:'POIDPT', index:'POIDPT', width:70},
      {name:'POINIT', index:'POINIT', width:70},
      {name:'TERMS', index:'TERMS', width:70},
    ],
postData: {POINIT : jQuery('#POINIT').val()},
    pager: '#pager',
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'PONUMB',
    sortorder: 'desc',
    viewrecords: true,
    caption: 'Purchase orders'
   }).navGrid('#gridpager',{view:false,edit:false,add:false, del:false}, 
{}, // use default settings for edit
{}, // use default settings for add
{},  // delete instead that del:false we need this
{multipleSearch : true}, // enable the advanced searching
{closeOnEscape:true} 
);

}); 

任何帮助将不胜感激。

【问题讨论】:

  • 这对我有用,所以我怀疑你要么没有设置你认为你在网格初始化中的内容,要么你正在覆盖它。我从来没有见过 postData 失败,我设置它就像你在上面做的那样。调试 val() 结果!

标签: javascript jquery jqgrid


【解决方案1】:

我的回复有点晚了,但诀窍是使用一个函数:

postData: {POINIT : function() { return $('#POINIT').val(); }}

【讨论】:

  • 我遇到了同样的问题,这解决了它。谢谢!
猜你喜欢
  • 1970-01-01
  • 2022-11-08
  • 1970-01-01
  • 2011-04-20
  • 2022-01-12
  • 2011-07-02
  • 2020-03-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多