如果 loadonce 设置为 true,JQGrid 子网格不会加载

发布于 2024-11-01 03:47:33 字数 2275 浏览 0 评论 0 原文

我有一个带有子网格(简单的子网格,而不是网格)的 JQGrid,直到昨天为止都运行良好。然后我发现了强大的标志 loadonce=true,它免费为我提供分页、搜索等功能。但是,由于我启用了加载,一旦子网格停止工作,当我单击加号展开一行时,加载框就会出现并且不会消失。如果我删除 loadonce=true 一切都会按预期工作。这是我的 javascript,提前致谢。

$("#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});

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});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑依然 2024-11-08 03:47:33

经过一些调试后,我发现您的错误非常简单:在您的网格中,您使用

subGridType: "xml"

而不是正确的

subgridtype: "xml"

(请参阅 文档)。因此,未知参数 subGridType 在当前网格中将被忽略,并且将使用 datatype 的值。在使用 loadonce:true 的情况下,在第一次网格加载后,datatype 的值更改为 local

此外,我建议您使用 unobtrusive JavaScript 来进行“点击”绑定。如果网格中有很多行,那么当前的实现会非常慢。请参阅答案描述了更有效的方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文