jqGrid与子网格错误的行选择



我有一个带有子网格的jqGrid。当我单击子网格的一行时,主网格上的同一行被选中。我真的不知道原因。

Jquery 3jquery ui 1.8.13jqGrid以下4.4.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。

(由OP简短回答,并在这里转录为社区维基回答)。参见没有答案的问题,但问题已在评论中解决(或在聊天中扩展))

OP写:

问题是主网格的行和子网格的行具有相同的ID!我解决了在JSON中为子网格提供不同的id。

相关内容

  • 没有找到相关文章

最新更新