当我们在某个字段上分组行时,我们如何为 JQG

How can we have global Expand/Collapse for JQGrid when we have rows grouped on some field?(当我们在某个字段上分组行时,我们如何为 JQGrid 进行全局展开/折叠?)
本文介绍了当我们在某个字段上分组行时,我们如何为 JQGrid 进行全局展开/折叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在某个字段上分组行时,如何为 JQGrid 进行全局展开/折叠?

How can we have global Expand/Collapse for JQGrid when we have rows grouped on some field?

展开时,应展开所有组,折叠时应折叠所有组.

On expanding, it should expand all groups and on collapsing all groups should be collapsed.

推荐答案

同样的方法可以设置jqGrid的groupingView参数的groupCollapse属性的默认值就像您设置任何其他默认参数一样:

You can set default value of the groupCollapse property of the groupingView parameter of jqGrid in the same way like you set any other default parameter:

$.extend($.jgrid.defaults, {
    groupingView: {
        groupCollapse: true
    }
});

已更新:在评论中进行了额外解释后,我可以想象在某些情况下,当 所有 组从组将被展开/折叠.

UPDATED: After additional explanation in the comments I can me imagine that in some cases it can has the behavior when all groups will be expanded/collapsed if any from the groups will be expanded/collapsed.

var $grid = $("#list"), inOnClickGroup = false;

$grid.jqGrid({
    // ... other options
    grouping: true,
    onClickGroup: function (hid) {
        var idPrefix = this.id + "ghead_", id, i, l,
            groups = this.p.groupingView.sortnames[0];

        if (!inOnClickGroup && hid.length > idPrefix.length &&
                hid.substr(0, idPrefix.length) === idPrefix) {
            id = Number(hid.substr(idPrefix.length));
            if (typeof (groups[id]) !== "undefined") {
                inOnClickGroup = true; // set to skip recursion
                for (i = 0, l = groups.length; i < l; i++) {
                    if (i !== id) {
                        $(this).jqGrid('groupingToggle', this.id + 'ghead_' + i);
                    }
                }
                inOnClickGroup = false;
            }
        }
    }
});

参见演示.

这篇关于当我们在某个字段上分组行时,我们如何为 JQGrid 进行全局展开/折叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)