带有子网格的jqGrid的全局展开/折叠按钮 [英] Global Expand/ collapse button for jqGrid with subgrids
问题描述
我正在将jqGRid与子网格配置一起使用来显示我的数据.我想在全球范围内扩展&折叠按钮以显示或隐藏所有子网格信息. jqGrid库是否通过任何方式提供此功能?
I am using jqGRid with subgrid configuration to display my data. I would like to have global expand & collapse button to display or hide all subgrid information. Does jqGrid library provide this feature by any means?
推荐答案
jqGrid没有全部展开/折叠".我修改了
jqGrid has no "Expand/Collapse all". I modified the demo from the old answer which demonstrates creating on grid with local subgrids. The resulting demo you can see here:
,并且在"subgrids"列的列标题中具有附加的"+"按钮.如果单击按钮,则所有子网格都将展开:
and it has additional "+" button in the column header of "subgrids" column. If one clicks on the button all subgrids will be expanded:
我在演示中使用了以下代码:
I used the following code in the demo:
var subGridOptions = $grid.jqGrid("getGridParam", "subGridOptions"),
plusIcon = subGridOptions.plusicon,
minusIcon = subGridOptions.minusicon,
expandAllTitle = "Expand all subgrids",
collapseAllTitle = "Collapse all subgrids";
$("#jqgh_" + $grid[0].id + "_subgrid")
.html('<a style="cursor: pointer;"><span class="ui-icon ' + plusIcon +
'" title="' + expandAllTitle + '"></span></a>')
.click(function () {
var $spanIcon = $(this).find(">a>span"),
$body = $(this).closest(".ui-jqgrid-view")
.find(">.ui-jqgrid-bdiv>div>.ui-jqgrid-btable>tbody");
if ($spanIcon.hasClass(plusIcon)) {
$spanIcon.removeClass(plusIcon)
.addClass(minusIcon)
.attr("title", collapseAllTitle);
$body.find(">tr.jqgrow>td.sgcollapsed")
.click();
} else {
$spanIcon.removeClass(minusIcon)
.addClass(plusIcon)
.attr("title", expandAllTitle);
$body.find(">tr.jqgrow>td.sgexpanded")
.click();
}
});
这篇关于带有子网格的jqGrid的全局展开/折叠按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!