jquery - jqGrid 在分组时对列进行排序考虑分组标题

标签 jquery jqgrid jqgrid-asp.net

我有jqgrid。我根据列值对几行进行了分组。工作演示可在 link 获取。 定义 jqGrid 的部分代码

    var preclosingtable = $('#preclosing');
    preclosingtable.jqGrid({
        datatype: 'local',
        data: data.DOCS,
        colNames: ['', 'Documents Received', 'Comments', 'NA', 'DocGroup'],
        colModel: [
        { name: 'Documents', index: 'Documents', align: 'left', sortable: false, editable: false, width: 20 },
        { name: 'DocsReceived', index: 'DocsReceived', align: 'center', sortable: false, editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: "checkbox", width: 140 },
        { name: 'Comments', index: 'Comments', align: 'center', sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "3", cols: "16" }, width: 180 },
        { name: 'NA', index: 'NA', editable: true, formatter: 'dynamicText', width: 150, edittype: 'custom', editoptions: { custom_element: radioelem, custom_value: radiovalue} },
            { name: 'DocGroup', index: 'DocGroup', editable: false, width: 1 }
        ],
        rowNum: data.DOCS.length,
        //rowList: [10, 20, 30],
        pager: '#preclosingpagerdiv',
        viewrecords: true,
        sortorder: "asc",
        sortname: 'Documents',
        grouping: true,
        groupingView: {
            groupField: ['DocGroup'],
            groupColumnShow: [false],
            groupDataSorted: true,
            groupOrder : 'asc'
        },
        localReader: {
            id: 'ConfigId'
        },
        shrinkToFit: false,
        height: 'auto',
        loadComplete: function () {
            HideGroupHeaders(this);
        },
        onSelectRow: function (id) {
            preclosingtable.jqGrid('saveRow', previouslyselectedRow, false, 'clientArray');
            previouslyselectedRow = SetJQGridRowEdit(id, previouslyselectedRow, preclosingtable);
        }
    });

以下是我的网格的样子 jqGrid after grouping

问题:是否可以对此网格中的行进行排序,以便最终网格中的行按以下顺序排列

  • 阿拉巴马州
  • D
  • 缅因州
  • 新泽西州
  • 弗吉尼亚州

最佳答案

如果我正确理解您的问题,您可以通过在进行分组的列 DocGroup 上添加自定义排序功能(请参阅 hereherehere )来解决您的问题:

sorttype: function (cellvalue, rowObject) {
    return cellvalue? cellvalue : rowObject.Documents;
}

因此,具有空 DocGroup 的输入数据将被排序,并按 Documents 分组。您将在 Fiddle 上看到结果

enter image description here

关于jquery - jqGrid 在分组时对列进行排序考虑分组标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16219944/

相关文章:

javascript - 将 UTC 字符串转换为 yyyy-mm-dd

javascript - jquery 未在 webpack 的 IIFE 中定义

javascript - 加载 jquery 时不工作

jquery - 在jqgrid中,如何让编辑表单在提交后消失

jquery - jqGrid动态解析网格寻呼机ID?

jquery - joint.js 在新的克隆元素上触发拖动开始

jqgrid - 如何在 jqgrid 中对格式化列值进行本地搜索?

javascript - JQGrid是免费的吗?

jqGrid 过滤器工具栏显示仅针对单列的搜索运算符选择器

javascript - 在 for 循环内为 .setTimeout() 创建闭包