不要在JQGrid中对单行进行分组

时间:2012-12-05 18:18:14

标签: jqgrid

我有一个将某些行组合在一起的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']
    },

1 个答案:

答案 0 :(得分:2)

我觉得你的问题很有意思。所以我编写的解决方案显示的是标准分组而不是标准分组(参见the starting demo

enter image description here

以下内容:

enter image description here

相应的代码并不复杂:

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只对组内的行进行排序。所以带有隐藏分组标题的上述行似乎不在排序过程中。

相关问题