【问题标题】:How can I make to show the subgrids from JQgrid by default?我怎样才能默认显示来自 JQgrid 的子网格?
【发布时间】:2014-01-28 14:01:46
【问题描述】:

TypeError: this.each 不是函数

return this.each(function () {这是我子网格序列中的代码:

subGrid : true, 

        subGridRowExpanded: function(subgrid_id, row_id) {
          //var projectIdRow = $('#list2').jqGrid('getCell',rowId,'projectid');
          var subgrid_table_id;
          subgrid_table_id = subgrid_id+"_t";
          $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"'></table>");
          $("#"+subgrid_table_id).jqGrid({
            url:"/taskuri/subGrid/?id="+row_id,
            datatype: "json",
            colNames: ['SubTask',' ','Pri','Responsabil','Alocator','Alocat','Deadline','Estimat','Lucrat',' '],
            colModel: [ 
              {name:"SubTask",index:"SubTask",width:'687%',align:"left",sortable:false},
              {name:'finished',index:'finished', width:'40%',sortable:false},
              {name:"Pri",index:"Pri",width:'56%', sortable:true},
              {name:"Responsabil",index:"Responsabil",width:'128%',sortable:false},
              {name:"Alocator",index:"Alocator",width:'130%',sortable:false},
              {name:"Alocat",index:"Alocat",width:'110%',sortable:false},
              {name:"Deadline",index:"Deadline",width:'110%',sortable:false},
              {name:"Estimat",index:"Estimat",width:'76%',align:"right",sortable:false},
              {name:"Lucrat",index:"Lucrat",width:'90%',align:"right"},
              {name:"Delete",index:"Delete",width:'90%',align:"right"},
            ],
            height: '100%',
            rowNum:20,
           });
        }, 

我想要的东西。首先默认显示子网格(当我访问页面时)。其次,如果那里没有数据,则没有点显示子网格。我怎样才能做到这一点?下面我上传一张图片,看看它是如何显示的,如果没有数据的话。谢谢

我试过这个方法:

gridComplete: function(){ 
               var grid = $("#list2");
               var svi_id = grid.jqGrid('getDataIDs');
               $.each(svi_id, function (index, rowId) {
                    $(this).jqGrid.expandSubGridRow(rowId); 
// or grid.jqGrid.expandSubGridRow(rowId); 

               });
        },

结果是一个错误:TypeError: this.each is not a function return this.each(function () { { (firebug)。怎么了?

【问题讨论】:

    标签: jqgrid default subgrid


    【解决方案1】:

    这是默认显示子网格的正确代码

     gridComplete: function(){ 
                       var grid = $("#list2");
                       var svi_id = grid.jqGrid('getDataIDs');
                       $.each(svi_id, function (index, rowId) {
                            grid.jqGrid('expandSubGridRow',rowId);
                       });
                },
    

    【讨论】:

      【解决方案2】:

      检查expandSubGridRow....您可以在父网格的加载完成中执行此操作!

          loadComplete: function () {
              var timeOut = 50;
              var rowIds = $("#list").getDataIDs();
              $.each(rowIds, function (index, rowId) {
                  setTimeout(function () {
                      $("#list").expandSubGridRow(rowId);
                  }, timeOut);
                  timeOut = timeOut + 200;
              });
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-11-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-18
        相关资源
        最近更新 更多