我有一个带子网格的jqGrid。当我单击subGrid的一行时,主网格上的同一行将被选中。我真的不知道原因。
我有 Jquery 1.4.3 jquery-ui 1.8.13 jqGrid 4.1.1这是代码:
$("#customer").jqGrid({
url:'/datasnap/rest/TMdsrl/CustomerTable/' + SessionData.SessionName,
datatype: "json",
mtype: 'GET',
colNames:['', '@lang.company','@lang.address', '@lang.zipcode', '@lang.city', '@lang.state', '@lang.vatid_code', '@lang.fiscal_code'],
colModel:[
{name:'CUSTOMER_ID',index:'CUSTOMER_ID', width:0, hidden:true},
{name:'COMPANY',index:'COMPANY', width:150},
{name:'ADDRESS',index:'ADDRESS', width:150},
{name:'ZIPCODE',index:'ZIPCODE', width:50},
{name:'CITY',index:'CITY', width:100},
{name:'STATE',index:'STATE', width:30},
{name:'VATID_CODE',index:'VATID_CODE', width:90},
{name:'FISCAL_CODE',index:'FISCAL_CODE', width:90}
],
rowNum:5,
rowList:[5,10,20],
pager: '#customer_pager',
sortname: 'COMPANY',
sortorder: "asc",
multiselect: false,
height: 250,
caption: "@lang.customer_title",
subGrid: true,
// define the icons in subgrid
subGridOptions: {
"plusicon" : "ui-icon-triangle-1-e",
"minusicon" : "ui-icon-triangle-1-s",
"openicon" : "ui-icon-arrowreturn-1-e"
},
subGridRowExpanded: function(subgrid_id, row_number) {
var subgrid_table_id, subpager_id;
var sub_rowdata = $("#customer").jqGrid('getRowData', row_number);
subgrid_table_id = subgrid_id+"_t";
subpager_id = "p_"+subgrid_table_id;
$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table> <div id='"+subpager_id+"' class='scroll'></div>");
$("#"+subgrid_table_id).jqGrid({
url:'/datasnap/rest/TMdsrl/ContactForCustomerTable/' + SessionData.SessionName + '/' + sub_rowdata.CUSTOMER_ID,
datatype: 'json',
mtype: 'GET',
colNames: ['','@lang.fullname','@lang.email','@lang.phone','@lang.cellphone', '@lang.newsletter'],
colModel: [
{name:'CONTACT_ID',index:'CONTACT_ID',width:0, hidden: true},
{name:'FULLNAME',index:'LASTNAME', width:150},
{name:'EMAIL',index:'EMAIL', width:150},
{name:'PHONE',index:'PHONE', width:150},
{name:'CELLPHONE',index:'CELLPHONE',width:150},
{name:'NEWSLETTER',index:'NEWSLETTER',width:20},
],
rowNum:5,
pager: subpager_id,
sortname: 'FULLNAME',
sortorder: 'asc',
height: '100%'
});
$("#"+subgrid_table_id).jqGrid('navGrid',"#"+subpager_id, {edit:false,add:false,del:false,search:false})
}
感谢您的帮助
解决 问题是主网格的行和子网格的行具有相同的ID!我解决了在JSON中为子网格提供不同的ID。
答案 0 :(得分:0)
(由OP简洁回答,并在此处转录为社区维基答案。请参阅Question with no answers, but issue solved in the comments (or extended in chat))
OP写道:问题是主网格的行和子网格的行具有相同的ID!我解决了在JSON中为子网格提供不同的ID。