在xceed DataGridControl中扩展所有组,包括嵌套 [英] Expanding all groups, including nested, in an xceed DataGridControl

查看:712
本文介绍了在xceed DataGridControl中扩展所有组,包括嵌套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以扩展单个组,但我的应用程序使用嵌套分组。我试图做如下的事情:

I am able to expand a single group fine, but my app uses nested groupings. Im attempting to do something as follows:

                foreach (CollectionViewGroup group in GridControl.Items.Groups)
                {
                    if (group != null)
                        GridControl.ExpandGroup(group);
                }

GridControl这里是一个DataGridControl。即使我有嵌套组,这里的项目只显示1个项目,但在循环中,该组可以在其VirtualizedItems中看到其子组,但不能在其Items中看到它的子组。我不认为我可以访问VirtualizedItems。

GridControl here is a DataGridControl. Even if i have nested groups, items here will only show 1 item, but inside the loop, the group can see its subgroup in its VirtualizedItems, but not in its Items. I dont think i can access the VirtualizedItems.

推荐答案

下面显示的代码片段可能会在您的场景中运行。我能够使用它来扩展/折叠所有组和子组。这在我们的DataVirtualization示例和不使用数据虚拟化的网格中都有效。另外,我没有必要首先滚动,即使是很大的行数。

Perhaps the code snippet shown below will work in your scenario. I was able to use it to expand/collapse all groups and sub-groups. This worked in both our DataVirtualization sample and with a grid that didn't use data virtualization. Also, I didn't have to scroll down first, even with a very large number of rows.

private void btnCollapseAllGroups_ButtonClick(object sender, RoutedEventArgs e)
{
    CollapseOrExpandAll(null, true);
}

private void btnExpandAllGroups_ButtonClick(object sender, RoutedEventArgs e)
{
    CollapseOrExpandAll(null, false);
}

private void CollapseOrExpandAll(CollectionViewGroup inputGroup, Boolean bCollapseGroup)
{
    IList<Object> groupSubGroups = null;

    // If top level then inputGroup will be null
    if (inputGroup == null)
    {
        if (grid.Items.Groups != null)
            groupSubGroups = grid.Items.Groups;
    }
    else
    {
       groupSubGroups = inputGroup.GetItems();
    }

    if (groupSubGroups != null)
    {

        foreach (CollectionViewGroup group in groupSubGroups)
        {
            // Expand/Collapse current group
            if (bCollapseGroup)
                grid.CollapseGroup(group);
            else
                grid.ExpandGroup(group);

            // Recursive Call for SubGroups
            if (!group.IsBottomLevel)
                CollapseOrExpandAll(group, bCollapseGroup);
        }
    }
}

这篇关于在xceed DataGridControl中扩展所有组,包括嵌套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆