我使用的是 jqGrid,我不能同时有 2 个子网格,如果单击第二个子网格,则应关闭前一个子网格。
我找不到一个事件来阻止这种情况...... 我需要类似的东西:
$("#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;
});
希望对其他人有帮助!
关于jqGrid,一次只显示一个子网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18769849/