开发者

JQGrid Subgrid doesn't load if loadonce is set to true

开发者 https://www.devze.com 2023-02-24 20:12 出处:网络
I have a JQGrid with a subgrid (simple one, not as a grid) which worked fine till yesterday. Then I discovered the powerful flag loadonce=true which gives me pagination, search, etc. for free. But sin

I have a JQGrid with a subgrid (simple one, not as a grid) which worked fine till yesterday. Then I discovered the powerful flag loadonce=true which gives me pagination, search, etc. for free. But since I have enabled loadonce the subgrid stopped working and when I click on the plus to expand a row the loading box appears and doesnt go away. If I remove loadonce=true everything works as expected. Here is my javascript, thanks in advance.

$("#testsTable").jqGrid({
    mtype: "POST",
    url: "GetCurrentStatusServlet",
    datatype: "xml",
    colNames:['Suite', 'Test Case', 'Last Update', 'Status','Actions'],
    colModel:[
              {name:'suite',index:'suite', width:50, sorttype:"int"},
              {name:'name',index:'name', width:300, formatter:nameFmatter},
              {name:'lastupdate',index:'lastupdate', width:150, formatter:"date"},
              {name:'status',index:'status', width:50, formatter: fmt_status,align:"center"},
              {name:'act',index:'act', width:100, align:"left"} 
              ],
              rowNum:150,
              width:1200,
              height:800,
              rowList:[150,300,500],
              pager: $('#pager1'),
              viewrecords: true,
              multiselect: true,
              caption: buildName,
              sortorder: "asc",
              sortname: "suite",
              subGrid: true,
              subGridUrl : "GetCurrentSubGridStatusServlet",
              subGridType: "xml",
              subGridModel: [ {
                  name:  ['Test Method', 'Last Update', 'Status'],
                  width : [250, 200, 100],
                  params: ['name']
              }],
            loadonce: true,
                  gridComplete: function(){
          开发者_Python百科            var ids = $("#testsTable").jqGrid('getDataIDs');
                      for(var i=0;i < ids.length;i++){
                          var cl = ids[i];

                          var test = new Array();
                          test.push($("#testsTable").getCell(cl, 'name'));
                          run = "<button class=\"runBtn\" onclick=\"runTests('"+test+"')\">Run</>"; 
                          log = "<button class=\"logBtn\" onclick=\";\">Log</>"; 
                          $("#testsTable").jqGrid('setRowData',ids[i],{act:run+log});
                      } 
                      setupButtons();
                  }
});
$("#testsTable").jqGrid('navGrid','#pager1',{add:false,edit:false,del:false});


After some debugging I found the your error is very easy: in your grid you use

subGridType: "xml"

instead of correct

subgridtype: "xml"

(see the documentation). So the unknown parameter subGridType will be just ignored in your current grid and the value of datatype will be used. The value of datatype are changed to local after the first grid loading in case of the usage of loadonce:true.

Additionally I would recommend you use unobtrusive JavaScript to make 'click' binding. You current implementation is very slow if you would have many rows in the grid. See the answer which described more effective way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号