重新填充JqGrid后,rowid在subGridRowExpanded中没有变化

时间:2016-06-05 06:17:57

标签: jqgrid jqgrid-asp.net

重新填充JqGrid后,rowid在subGridRowExpanded中没有变化。

请找到以下代码..



Grid: function(gridEntity, filter) {

    var MyGrid = {

        Params: {
          datatype: function(postData) {
            $.ajax({
              url: "TestPage.aspx/GetTestData",
              type: "POST",
              data: [],
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(data, status) {
                $("#grid").clearGridData();
                Entity = JSON.parse(data.d);
                var rowId = Entity.length + 1;
                $("#grid").addRowData(rowId, Entity, "last");
              }
            });
          },
          height: 'auto',
          rowNum: 100,
          page: 1,
          rowList: [10, 50, 100],
          pager: '#pager',
          viewrecords: true,
          subGrid: true,

          jsonReader: {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: true,
            cell: "cell",
            id: "id",
            userdata: "userdata",
            subgrid: {
              root: "rows",
              repeatitems: true,
              cell: "cell"
            }
          },

          subGridRowExpanded: function(subgridId, rowId) {

            rowId = parseInt(rowId.replace("jqg", ""), 10);

            var subGrid = {};
            subGrid.rows = Entity.rows[rowId - 1].SubgridRows;
            var subgridTableId = subgridId + "_t";
            $("#" + subgridId).html("<table id='" + subgridTableId + "'></table>");
            $("#" + subgridTableId).jqGrid({
              datatype: "local",
              data: subGrid.rows,
              colNames: ['Teacher', 'Subject'],
              colModel: [{
                name: 'Teacher',
                align: "center",
                width: 200,
                sortable: false
              }, {
                name: 'Subject',
                width: 100,
                align: "center",
                sortable: false
              }],
              height: "100%",
              rowNum: 10,
              idPrefix: "s_" + rowId + "_"
            });

          },

          caption: 'Test Grid',
          colNames: ["Name", "Addr",

            colModel: [{
                name: "Name",
                width: 40,
                sortable: false
              },

              {
                name: "Addr",
                width: 60,
                sortable: false
              }
            ],
            pager: "#pager"
          },

        };
      },


      Reload: function(postData) {
        $.ajax({
          url: "TestPage.aspx/GetTestData",
          type: "POST",
          data: [],
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(data, status) {
            $("#grid").clearGridData();
            Entity = JSON.parse(data.d);
            var rowId = Entity.length + 1;
            $("#grid").addRowData(rowId, Entity, "last");
          }
        });
      },
      Data: Entity,
&#13;
&#13;
&#13;

请查看subGridRowExpanded 当我重新加载网格时,&#34; rowId&#34;不会改变。 最初说我有100行,但过滤后我得到10行。 然后,如果我扩展第一行以查看子网格,则rowId类似于&#34; jqg50&#34; .. 我需要rowId为&#34; jqg1&#34;或&#34; 1&#34;这样我就可以过滤实体以填充子网格.. 要么 当我点击&#34; +&#34;有没有办法让rowId = 1;重新填充后网格中的图标? 任何帮助将不胜感激..

0 个答案:

没有答案