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 に答える