Javascript jquery子网格与json

Javascript jquery子网格与json,javascript,jquery,grid,jqgrid,Javascript,Jquery,Grid,Jqgrid,我在jqgrid工作。我需要实现网格的子网格。我的代码如下: <div class="ww90p"> <!-- class="sheet"--> <div class="" > <table id="setcols" class="scroll"> </table> <div id="psetcols" class="scroll"></div> </div> </div&

我在jqgrid工作。我需要实现网格的子网格。我的代码如下:

<div class="ww90p">
<!-- class="sheet"--> 
<div class="" >
    <table id="setcols" class="scroll">   </table>
    <div id="psetcols" class="scroll"></div>
</div>
</div>

$("#setcols").jqGrid(
    $.extend( {}, jqGrid_normal, {
    url: "/account/chartjson/?{{ query_fragment }}&nd="+new Date().getTime(),
    caption: "&nbsp;",
    colModel:[
        {name:'number', width:50, label: "Number", sortable:false },
        {name:'name', width:300, label: "Name", sortable:false },
        {name:'opening_date', label: "Opening Date", width:150, sortable:false },
        {name:'balance', label: "Balance", width: 100, sortable:false,align:'right' }
    ],
    pager: '#psetcols',
    sortname: 'number',
    sortorder: "desc",
    multiselect: true,
    viewrecords: true, 
    footerrow : true,
    userDataOnFooter : true,
    subGrid: true,
    subGridUrl :"/account/subgridjson/?{{ query_fragment }}&nd="+new Date().getTime(),
    subGridModel: [
             { name : ['number','name','opening_date','balance'], width : [55,200,80,80] }
        ]
}));

$(“#setcols”).jqGrid(
$.extend({},jqGrid_normal{
url:“/account/chartjson/?{query_fragment}}&nd=“+new Date().getTime(),
标题:“,
colModel:[
{名称:'number',宽度:50,标签:“number”,可排序:false},
{name:'name',width:300,label:“name”,sortable:false},
{名称:'opening_date',标签:“opening date”,宽度:150,可排序:false},
{name:'balance',label:'balance',width:100,sortable:false,align:'right'}
],
传呼机:“#psetcols”,
sortname:'编号',
巫师:“描述”,
多选:对,
viewrecords:是的,
是的,
userDataOnFooter:true,
子网格:对,
subGridUrl:“/account/subgridjson/?{query_fragment}}&nd=“+new Date().getTime(),
子网格模型:[
{name:['number','name','opening_date','balance',宽度:[55200,80,80]}
]
}));
子网格的JSON文件输出:

{
    rows: [
        {type: "4", number: "101", name: '<a href="/ledger/view_by_account?account_id=3">Bank (123456789
)</a>', opening_date: "2009-05-12", balance: "0.000000"}
    ]
}
{
行:[
{类型:“4”,编号:“101”,名称:'',开盘日期:“2009-05-12”,余额:“0.000000”}
]
}
但错误是:

cur is undefined [Break on this error] for (var j=0;j<cur.length;j++) {...... cur未定义
[Break on this error]对于(var j=0;j我发现更容易转储内置子网格,并使用其“子网格即网格”示例动态插入全新网格:

subGrid:true,
subGridRowExpanded:函数(subgrid\u id,row\u id){
//我们传递两个参数
//subgrid_id是在表中创建的div标记的id
//row\u id是该行的id
//如果我们想向url传递额外的参数,我们可以使用
//方法getRowData(row_id)-返回类型名称值中的关联数组
//在这里,我们可以简单地构造以下内容
var子网格\u表\u id;
子网格\表\ id=子网格\ id+“\ t”;
jQuery(“#”+子网格id).html(”;
jQuery(“#”+子网格_表_id).jqGrid({
url:“subgrid.php?q=2&id=“+row\u id,
数据类型:“xml”,
colNames:['No','Item','Qty','Unit','Total'],
colModel:[
{name:“num”,index:“num”,宽度:80,键:true},
{名称:“项”,索引:“项”,宽度:130},
{名称:“数量”,索引:“数量”,宽度:80,对齐:“右”},
{名称:“单位”,索引:“单位”,宽度:80,对齐:“右”},
{name:“total”,index:“total”,width:100,align:“right”,sortable:false}
],
身高:100%,
rowNum:20,
sortname:'num',
分拣员:“asc”
});

我发现转储内置子网格并使用其“子网格即网格”示例更容易在运行中插入全新网格:

subGrid:true,
subGridRowExpanded:函数(subgrid\u id,row\u id){
//我们传递两个参数
//subgrid_id是在表中创建的div标记的id
//row\u id是该行的id
//如果我们想向url传递额外的参数,我们可以使用
//方法getRowData(row_id)-返回类型名称值中的关联数组
//在这里,我们可以简单地构造以下内容
var子网格\u表\u id;
子网格\表\ id=子网格\ id+“\ t”;
jQuery(“#”+子网格id).html(”;
jQuery(“#”+子网格_表_id).jqGrid({
url:“subgrid.php?q=2&id=“+row\u id,
数据类型:“xml”,
colNames:['No','Item','Qty','Unit','Total'],
colModel:[
{name:“num”,index:“num”,宽度:80,键:true},
{名称:“项”,索引:“项”,宽度:130},
{名称:“数量”,索引:“数量”,宽度:80,对齐:“右”},
{名称:“单位”,索引:“单位”,宽度:80,对齐:“右”},
{name:“total”,index:“total”,width:100,align:“right”,sortable:false}
],
身高:100%,
rowNum:20,
sortname:'num',
分拣员:“asc”
});
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
// we pass two parameters
// subgrid_id is a id of the div tag created within a table
// the row_id is the id of the row
// If we want to pass additional parameters to the url we can use
// the method getRowData(row_id) - which returns associative array in type name-value
// here we can easy construct the following
   var subgrid_table_id;
   subgrid_table_id = subgrid_id+"_t";
   jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
   jQuery("#"+subgrid_table_id).jqGrid({
      url:"subgrid.php?q=2&id="+row_id,
      datatype: "xml",
      colNames: ['No','Item','Qty','Unit','Total'],
      colModel: [
        {name:"num",index:"num",width:80,key:true},
        {name:"item",index:"item",width:130},
        {name:"qty",index:"qty",width:80,align:"right"},
        {name:"unit",index:"unit",width:80,align:"right"},           
        {name:"total",index:"total",width:100,align:"right",sortable:false}
      ],
      height: 100%,
      rowNum:20,
      sortname: 'num',
      sortorder: "asc"
   });