postData for subgrid in jqgrid not working?

家住魔仙堡 提交于 2019-12-01 03:43:31

问题


Hi I have a jqgrid with a subgrid which calls into a servlet. I am sending some data to the servlet using POST but the same data doesn't get sent when the call for the subgrid is made. This is my JS:

$("#testsTable").jqGrid({
  mtype: "POST",
  url: "GetCurrentStatusServlet",
  postData: {buildPath :"C:\\Test\\01"},
  datatype: "xml",
     colNames:['TestCase Name', 'Last Update', 'Status'],
     colModel:[
      {name:'name',index:'name', width:90},
      {name:'lastupdate',index:'lastupdate', width:100},
      {name:'status',index:'status', width:80, align:"right"}   
     ],
     rowNum:10,
     autowidth: true,
     rowList:[10,20,30],
     pager: $('#pager1'),
     sortname: 'id',
     viewrecords: true,
     multiselect: true,
  caption: "Tests",
     sortorder: "desc",
     subGrid: true,
     subGridUrl : "GetCurrentStatusServlet",
     subGridModel: [ {
       name:  ['TestCase Name', 'Last Update', 'Status'],
       width : [100, 200, 80],
       params: ['name']}]
 }).navGrid('#pager1',{edit:false,add:false,del:false}); 

So how can I postData also to the subgrid servlet? is there any way to specify subgridPostData? Thanks.


回答1:


I find the suggestion with subgridPostData good. Probably you should post the corresponding feature request in the trirand forum.

Now you can implement the same feature itself using serializeSubGridData event. Just define a new jqGrid parameter with the name which you like, for example subgridPostData and use it inside of your serializeSubGridData event handler:

$("#testsTable").jqGrid({
    ...
    subGrid: true,
    subGridUrl: "GetCurrentStatusServlet",
    subgridPostData: {foo: "bar"},
    serializeSubGridData: function(postdata) {
        return $.extend(postdata, this.p.subgridPostData);
    },
    ...
});


来源:https://stackoverflow.com/questions/4449130/postdata-for-subgrid-in-jqgrid-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!