jqGrid,一次仅显示一个子网格

jqGrid,一次仅显示一个子网格,jqgrid,subgrid,Jqgrid,Subgrid,我使用的是jqGrid,我不能同时拥有两个子网格,如果单击第二个子网格,那么前一个子网格应该关闭 我找不到一个事件来阻止这一切。。。 我需要像这样的东西: $("#list2").jqGrid({ multiSubGrids: false }); 也许是我错过了什么 提前谢谢 我找到了这个方法。。。它很管用,但我不知道它是否是最好的: // this will save the rowId of the previous subGrid var previousRowId =

我使用的是jqGrid,我不能同时拥有两个子网格,如果单击第二个子网格,那么前一个子网格应该关闭

我找不到一个事件来阻止这一切。。。 我需要像这样的东西:

$("#list2").jqGrid({
        multiSubGrids: false
});
也许是我错过了什么


提前谢谢

我找到了这个方法。。。它很管用,但我不知道它是否是最好的:

// this will save the rowId of the previous subGrid
var previousRowId = 0;

$("#list2").jqGrid({
    // all your default mapping here..  
    ...
    subGridRowExpanded: function (subgrid_id, row_id) {
    if (previousRowId != 0) {
        $(this).collapseSubGridRow(previousRowId);
    }   
    ...
    // all your subgrid code here
    ...
    // this will save the actual row_id,
    // so the next time a subgrid is going to be expanded,
    // it will close the previous one
    previousRowId = row_id; 
});

希望它能帮助别人

我找到了这个方法。。。它很管用,但我不知道它是否是最好的:

// this will save the rowId of the previous subGrid
var previousRowId = 0;

$("#list2").jqGrid({
    // all your default mapping here..  
    ...
    subGridRowExpanded: function (subgrid_id, row_id) {
    if (previousRowId != 0) {
        $(this).collapseSubGridRow(previousRowId);
    }   
    ...
    // all your subgrid code here
    ...
    // this will save the actual row_id,
    // so the next time a subgrid is going to be expanded,
    // it will close the previous one
    previousRowId = row_id; 
});
希望它能帮助别人

从这里开始:

使用
subGridRowExpanded:function(subgrid\u id,row\u id){…}
可以捕获事件

$("#list2 tr:has(.sgexpanded)").each(function () {
    num = $(this).attr('id');
    $(this).collapseSubGridRow(num);
});
您可以折叠所有展开的子网格行。

从这里:

使用
subGridRowExpanded:function(subgrid\u id,row\u id){…}
可以捕获事件

$("#list2 tr:has(.sgexpanded)").each(function () {
    num = $(this).attr('id');
    $(this).collapseSubGridRow(num);
});

您可以折叠所有展开的子网格行。

我尝试了Luis建议的解决方案,但无效

这个很有魅力:


我尝试了路易斯提出的解决方案,但没有成功

这个很有魅力:


与前面的答案不同的是,我将通过迭代
具有类
.sgexpanded
的每个
子网格,确保关闭所有展开的
子网格,不是只关闭
最后一个
?与前面的答案不同的是,我将确保通过迭代
具有类
.sgexpanded
的每个
子网格来关闭所有展开的
子网格,而不是只关闭
最后一个