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

标签 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']
    },

最佳答案

我觉得你的问题很有趣。所以我编写了显示而不是标准分组的解决方案(请参阅 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 仅对组内的行进行排序。因此,上面带有隐藏分组标题的行似乎不在排序过程中。

关于jqgrid - 不要在 JQGrid 中对单行进行分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13729790/

相关文章:

jquery - JqG​​rid的Row默认选中

php - 无法以json格式将数据从php添加到jqGrid

javascript - jqGrid - onClickButton 用工具提示值替换单元格值,反之亦然

javascript - jqgrid 内联编辑时日期选择器中的 minDate

jquery - 将 jqGrid 行数据从 View 提交到 Controller - 什么方法?

php - JqG​​rid 编辑表单不在下拉列表中显示正确的项目

jquery - 将数组作为 postData 参数发送

javascript - 带动态列的 JQGrid : cellattr does not work

javascript - 我需要 sme 帮助自动化 jqGrid 过滤器,拜托

jquery - 免费 jqGrid - 显示/隐藏列(如果为空)