jqGrid subGrid 滚动后停止打开

发布于 2024-12-10 09:53:06 字数 1443 浏览 1 评论 0原文

我有一个使用 subGrid 的网格(版本 4.1.1)。我正在使用 loadonce: true 和scroll: 1。当网格首次加载时,我可以毫无问题地打开子网格,直到我将主网格向下滚动到加载更多数据的位置。之后,子网格将不会打开或关闭。如果我单击加号图标,我会看到“正在加载...”,但没有任何反应。我什至无法关闭之前打开的子网格。

这是我的网格定义:

$("#grid_sites").jqGrid({
url:'getgridxmlsites.php',
      postData: {detailid: function() {return $('#hdnDetailId').val(); }},
datatype: 'xml',
height: 260,
width: 832,
shrinkToFit: false,
caption:'',
colNames :['studydetailid', 'Site', 'Name', 'Status', 'Location'],
colModel :[
   {name:'detailid',     index:'detailid', width:0, hidden: true },
   {name:'sitenumber',   index:'sitenumber',    width:60,   align:'right'},
   {name:'name',         index:'name',      width:230},
   {name:'status',       index:'status',        width:110,  align:'center'},
         {name:'location',       index:'location',  width:74}
       ],
 pager:'pager_sites',
 scroll: 1,
 viewrecords:true,
 sortable:true,
 sortname: 'sitenumber',
 autowidth: true,
 pgbuttons: false,
 loadonce: true,
//      gridview: true, // Cannot be used when using subGrid.
 onSelectRow: function(id){ gridRowSelect(id) },
 subGrid: true,
 subGridUrl: 'getgridxmldatabysite.php',
 subgridtype: 'xml',
 subGridModel: [{
        name: ['Owner', 'Phone', 'Status'],
        width: [120, 100, 100],
        align: ['left', 'left', 'left'],
        params: ['detailid']
    }],
  subGridOptions: { reloadOnExpand : false }
});

希望对您有所帮助。

I have a grid (version 4.1.1) using a subGrid. I'm using loadonce: true and scroll: 1. When the grid first loads, I can open subGrids with no problem, until I scroll the main grid down to the point where it loads more data. After that, no subgrid will open or close. If I click on the plus icon, I see the "Loading...", but nothing happens. I can't even close the subGrids that were previously opened.

Here is my grid definition:

$("#grid_sites").jqGrid({
url:'getgridxmlsites.php',
      postData: {detailid: function() {return $('#hdnDetailId').val(); }},
datatype: 'xml',
height: 260,
width: 832,
shrinkToFit: false,
caption:'',
colNames :['studydetailid', 'Site', 'Name', 'Status', 'Location'],
colModel :[
   {name:'detailid',     index:'detailid', width:0, hidden: true },
   {name:'sitenumber',   index:'sitenumber',    width:60,   align:'right'},
   {name:'name',         index:'name',      width:230},
   {name:'status',       index:'status',        width:110,  align:'center'},
         {name:'location',       index:'location',  width:74}
       ],
 pager:'pager_sites',
 scroll: 1,
 viewrecords:true,
 sortable:true,
 sortname: 'sitenumber',
 autowidth: true,
 pgbuttons: false,
 loadonce: true,
//      gridview: true, // Cannot be used when using subGrid.
 onSelectRow: function(id){ gridRowSelect(id) },
 subGrid: true,
 subGridUrl: 'getgridxmldatabysite.php',
 subgridtype: 'xml',
 subGridModel: [{
        name: ['Owner', 'Phone', 'Status'],
        width: [120, 100, 100],
        align: ['left', 'left', 'left'],
        params: ['detailid']
    }],
  subGridOptions: { reloadOnExpand : false }
});

I hope you can help.

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

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

发布评论

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

评论(3

温暖的光 2024-12-17 09:53:06

我遇到了类似的问题。看起来 jqgrid 中的 addSubGrid 函数正在添加一个单击事件,以将子网格切换到表中的每一行(而不仅仅是刚刚加载的行)。

这导致新行表现良好,但第一组快速展开然后折叠(两个单击处理程序)。当加载另一组数据时,第一组行工作正常(尽管它们会展开、折叠,然后再次展开),但第二组行不再工作。

当我试图弄清楚我是否丢失了 JSON 中的某些行元数据时,我有点迷失在 addJSON 和 addSubGrid 的组合中。现在我只是将行:修改

$(ts.rows[i].cells[pos]).bind('click', function(e) {

为:

$(ts.rows[i].cells[pos]).unbind('click');
$(ts.rows[i].cells[pos]).bind('click', function(e) {

,一切似乎都按预期工作。这是针对 jqGrid 4.2.0 版本的。我仍然不确定这是一个错误、配置问题还是数据问题,但至少我又开始工作了。

I am experiencing a similar problem. It looks like the addSubGrid function in jqgrid is adding a click event to toggle the subgrid to every row in the table (not just the ones that were just loaded).

This was causing the new rows to behave fine but the first set to rapidly expand and then collapse (two click handlers). When another set of data got loaded the first set of rows worked fine (although they'd expand, collapse, and expand again) but the second set no longer worked.

I got kind of lost in the combination of addJSON and addSubGrid when trying to figure out if I was missing some of the row metadata in the JSON. For now I just modified the line:

$(ts.rows[i].cells[pos]).bind('click', function(e) {

to:

$(ts.rows[i].cells[pos]).unbind('click');
$(ts.rows[i].cells[pos]).bind('click', function(e) {

and everything seems to work as expected. This is for version 4.2.0 of jqGrid. I'm still not sure if this is a bug, a configuration problem, or a data problem but at least I'm working again.

内心激荡 2024-12-17 09:53:06

通常,“正在加载...” 表示处理服务器响应时出现错误。我建议您使用 jquery.jqGrid.src.js 而不是 jquery.jqGrid.min.js 并在调试器中启动页面。例如,您可以使用 Internet Explorer 的开发人员工具。为此,您应该按 F12 启动开发人员工具,然后选择“脚本”并单击“开始调试”按钮。该页面将因错误而停止,或者您将在右侧窗格的“Cosole”中看到一些附加信息。

由于数据处理的复杂性和不同的已知错误或问题,我个人不使用 scroll: 1 选项。在我看来,您使用了不兼容的参数组合。我建议您删除 loadonce: truescroll: 1 参数。

Typical the "Loading..." means an error in the processing of the server response. I recommend you to use jquery.jqGrid.src.js instead of jquery.jqGrid.min.js and to start your page in the debugger. For example you can use Developer Tools of Internet Explorer. Do do this you should press F12 to start Developer Tools, then choose "Script" and click on "Start debugging" button. Either the page will be stopped on error or you will be see some additional information in the "Colsole" on the right pane.

I personally not use scroll: 1 option because of complexity of the data processing and different known bugs or problems. It seems to me that you use incompatible combination of parameters. I would recommended you to remove either loadonce: true or scroll: 1 parameter.

扭转时空 2024-12-17 09:53:06

在您的配置中,您没有设置 rowNum。所以我相信jqgrid将使用默认的rowNum,即20。由于Robert Simmons提到的点击绑定问题,这会导致滚动问题。

无需更改 jqgrid 代码即可解决此问题的另一种方法是将 rowNum 设置为 -1。这只会获取所有行,这应该没问题,因为您正在使用本地数据。然而,此修复可能不适用于 4.6.0 之前的版本。 (请参阅如何显示 jqGrid 中的所有行?有关将 rowNum 设置为 -1 的更多信息)。在 4.6.0 之前的版本中,我认为主要解决方案是将 rowNum 设置为一个较大的数字。

In your configuration, you do not set rowNum. So I believe jqgrid will use the default rowNum which is 20. This causes the scrolling issue due to the click binding issue mentioned by Robert Simmons.

Another way to fix this issue without having to change the jqgrid code is to set the rowNum to -1. This will just get all rows, which should be fine because you are using local data. This fix may not work in previous versions to 4.6.0 however. (See How to show all rows in the jqGrid? for more info on setting rowNum to -1). In versions prior to 4.6.0 I think the main solution was to just set rowNum to a large number.

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