不要在JQGrid中对单行进行分组 [英] Don't Group Single Rows in JQGrid
问题描述
我有一个将某些行组合在一起的JQGrid.我使用group
定义应该将哪些行分组在一起,因此,例如,如果有三个2
,它将所有2
分组在一起.但是,可能只有一个2
,在这种情况下,我不想将其分组,即将行放在一个组下.
I have a JQGrid that groups together certain rows. I use group
to define what rows should grouped together, so for example, if there are three 2
s, it groups all 2
s together. However it's possible there could be only one 2
, in which case I wouldn't want it grouped, i.e. having the row under a group.
我的问题是,是否可以将分组仅应用于某些行而将其他行留空?
My question is, is it possible to have the grouping only be applied to certain rows and leave others alone?
以下是我目前所拥有的:
Below is what I currently have:
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']
},
推荐答案
我发现您的问题很有趣.因此,我写了一个解决方案,该解决方案显示的不是标准分组(请参见初始演示)
I find your question interesting. So I wrote the solution which shows instead of the standard grouping (see the starting demo)
以下内容:
相应的代码不是那么复杂:
The corresponding code is not so complex:
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();
}
}
}
它使用一个一级分组,但是可以通过与多层分组相同的方式进行更改.
It uses one level grouping, but it can be changed in the same way to the multilevel grouping.
关于生成的网格的一个警告:对网格进行排序时应格外小心.问题是jqGrid仅对组内的行进行排序.因此,上面带有隐藏的分组标题的行似乎不在排序过程之列.
One warning about the resulting grid: you should be careful with sorting of the grid. The problem is that jqGrid sort the rows inside of the group only. So the above rows with hidden grouping headers seems be out of sorting process.
这篇关于不要在JQGrid中对单行进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!