使用URL发布row_id:扩展jqgrid以加载子网格时

时间:2012-12-18 09:31:06

标签: jqgrid jqgrid-php

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

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作为数组。

1 个答案:

答案 0 :(得分:0)

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

used postDATA:一个直接附加到网址的关联数组。

postData: {prodcutid: row_id}
相关问题