jqGrid with subGrid faulty row selection
I have a jqGrid with a subGrid. When I click on a row of the subGrid, the same row on the main grid becomes selected. I really don't know the reason.
I have Jquery 1.4.3 jquery-ui 1.8.13 jqGrid 4.1.1
here is the code:
$("#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})
}
Thank you for your help
SOLVED The problem was that rows of the main grid and开发者_如何学编程 rows of the subgrid had the same ID! I solved giving different ids for the subgrid in the JSON.
(Answered tersely by the OP and transcribed here as a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
The problem was that rows of the main grid and rows of the subgrid had the same ID! I solved giving different ids for the subgrid in the JSON.
精彩评论