1

在扩展网格时,我试图通过将父行键 (dept_id) 发布到 url:'sub_grid_load_dept.php' 来将 jqgrid 作为子网格加载。但是不知道如何以简单的方式做到这一点。这是我的代码

jQuery("#grid-dept").jqGrid({
    url:'grid_load_dept.php',
    datatype: "xml",

    colNames:['dept id','dept prefix','dept name'],
    colModel:[
     {name:'dept_id',index:'dept_id', width:200, editable: true},
     {name:'dept_prefix',index:'dept_prefix', width:200, editable: true},
     {name:'dept_name',index:'dept_name', width:200, editable: true}
    ],
    loadonce:false,
    mtype: "POST",
    pager: '#grid-dept-pager',
    sortname: 'dept_id',
    sortorder: "asc",
    editable: true, 
    caption: "department",
    editurl:"grid_edit_dept.php",
    subGrid: true,
    subGridRowExpanded: function(subgrid_id, row_id) 
        {
           var subgrid_table_id;
           var pager_id;
           subgrid_table_id = subgrid_id+"_t";
           pager_id = "p_"+subgrid_table_id;
           $("#" + subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+ pager_id +"' class='scroll'></div>");
           $("#" + subgrid_table_id).jqGrid({
              url:'sub_grid_load_dept.php',
              datatype: "xml",
              colNames: ['id','dept_id','office_id','dept_head','date_from','date_to','remarks'],
              colModel:
              [
                {name:"id",index:"id",width:80,key:true, editable:true},
                {name:"dept_id",index:"dept_id",width:130, editable:true},
                {name:"office_id",index:"office_id",width:80,align:"right", editable:true},
                {name:"dept_head",index:"dept_head",width:80,align:"right", editable:true},           
                {name:"date_from",index:"date_from",width:100,align:"right", editable:true},
                {name:"date_to",index:"date_to",width:100,align:"right", editable:true},
                {name:"remarks",index:"remarks",width:100,align:"right", editable:true}
              ],
              caption: "Department Details",
              mtype: "POST",
              sortname: 'id',
              sortorder: "asc",
              editable: true,
              pager:pager_id,
              editurl:"sub_grid_edit_dept.php"
           });
         jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:true,add:true,del:false,search:true,refresh:true})
   }

我的意思是如何在 subGridRowExpanded: function(subgrid_id, row_id) 中发布 'row_id' 通过包含在 URL: proterty.maybe 作为一个数组。

4

1 回答 1

0

我找到了解决方案:[http://stackoverflow.com/questions/12823591/how-to-pass-the-selected-row-id-to-the-subgrids-url-in-jqgrid][1]

使用的 postDATA:直接附加到 url 的关联数组。

postData: {prodcutid: row_id}
于 2012-12-19T05:21:35.123 回答