我有一个 JQGrid 将某些行组合在一起。我使用group
来定义哪些行应该分组在一起,例如,如果有三个2
,它将所有2
分组在一起。但是,可能只有一个 2
,在这种情况下,我不希望将其分组,即将该行放在一个组下。
我的问题是,是否可以将分组仅应用于某些行而忽略其他行?
以下是我目前拥有的:
colNames:['group', 'Description', 'File Sent to Customer', 'Date/Time', 'ATS', '# of Bib Records', '# of Items', 'Customer DB', 'Customer ID'],
colModel:[
{name:'group', index:'group'},
{name:'description', index:'description'},
{name:'fileSent', index:'fileSent', width:150},
{name:'date', index:'date', width:160},
{name:'ats', index:'ats', width:100},
{name:'bibRecords', index:'bibRecords', width:100},
{name:'items', index:'items', width:100},
{name:'customerDB', index:'customerDB', width:240},
{name:'customerID', index:'customerID', width:150}
],
grouping:true,
groupingView : {
groupField : ['group'],
groupColumnShow : [false],
groupText : [''],
groupCollapse : true,
groupOrder: ['desc']
},
最佳答案
我觉得你的问题很有趣。所以我编写了显示而不是标准分组的解决方案(请参阅 the starting demo )
以下内容:
对应的代码没那么复杂:
loadComplete: function () {
var i, groups = $(this).jqGrid("getGridParam", "groupingView").groups,
l = groups.length,
idSelectorPrefix = "#" + this.id + "ghead_0_";
for (i = 0; i < l; i++) {
if (groups[i].cnt === 1) {
// hide the grouping row
$(idSelectorPrefix + i).hide();
}
}
}
它使用一级分组,但可以以与多级分组相同的方式更改。
关于生成的网格的一个警告:您应该小心网格的排序。问题是 jqGrid 仅对组内的行进行排序。因此,上面带有隐藏分组标题的行似乎不在排序过程中。
关于jqgrid - 不要在 JQGrid 中对单行进行分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13729790/