1

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(){
                      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});
Tarelli
  • 634
  • 7
  • 18
  • If you use `subGridType:"xml"`, you should have no problem with `loadonce:true` parameter at least in the theory. Of course including `loadonce:true` follow to executing another code. If you has a live example the url could help to analyse the problem. If you post more full example which can be used to reproduce the problem I could try to help you. – Oleg Apr 15 '11 at 22:05
  • any example would do. add loadonce=true there for instance http://www.secondpersonplural.ca/jqgriddocs/_2eb0giikm.htm – Tarelli Apr 16 '11 at 00:18
  • also found similar question http://stackoverflow.com/questions/4316422/jqgrid-problem-binding-subgrid – Tarelli Apr 16 '11 at 00:22

1 Answers1

4

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.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798