Home Forums WPF controls Xceed DataGrid for WPF How to collapse groups?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25885 |

    Does anyone know how I can collapse all groups after loading a grid? I can’t figure out how to access a CollectionViewGroup collection. I see “Groups” and “GroupDescriptions”, but neither returns CVG objects.

    gridGroupDescriptions.Clear();

    this.TestGrid.Items.GroupDescriptions.Add(new Xceed.Wpf.DataGrid.DataGridGroupDescription(“State”));
    this.TestGrid.Items.GroupDescriptions.Add(new Xceed.Wpf.DataGrid.DataGridGroupDescription(“City”));

    ??? enumerate anything ???
    this.TestGrid.CollapseGroup(??????);

    Imported from legacy forums. Posted by Todd (had 4394 views)

    Xceed Support
    Member
    Post count: 5658

    You can set a GroupLevelConfiguration’s InitiallyExpanded property to false.

    dataGridControl.View.GroupLevelConfigurations.Add( … )

    you can also call the grid’s CollapseGroup method.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 391 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the reply. Unfortunately, I don’t know how to do either!

    In the example I provided, I’m adding groups programmatically.

    I have not been able to figure out how to get hold of groups in order to pass them to the CollapseGroup method!

    Imported from legacy forums. Posted by Todd (had 648 views)

    Xceed Support
    Member
    Post count: 5658

    Take a look at this topic in the documentation, it should help you accomplish what you want ūüôā

    <a href=”http://doc.xceedsoft.com/products/XceedWpfDataGrid/Retrieving%20a%20parent%20group.html”>Retrieving a parent group</a>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 867 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, Jen.

    Using that example, I’d need to have an item to start with. I just wanted to collapse everything. I’d assume it to be inefficient for me to enumerate all items, repeatedly calling collapse.

    Meanwhile, using the example you referred me to, I was able to get them collapsed through xaml:

    <xcdg:DataGridControl.View>
    <xcdg:TableView>
    <xcdg:TableView.GroupLevelConfigurations>
    <xcdg:GroupLevelConfiguration InitiallyExpanded=”False”>
    </xcdg:GroupLevelConfiguration>
    </xcdg:TableView.GroupLevelConfigurations>
    </xcdg:TableView>
    </xcdg:DataGridControl.View>

    Is there really no way to enumerate groups???

    Imported from legacy forums. Posted by Todd (had 878 views)

    Xceed Support
    Member
    Post count: 5658

    If you want to start your groups collapsed, then the best way to do it is by using the InitiallyCollapsed property. That said, if you want to enumerate the groups, you can go through the DataGridControl.Items.Groups property; however, these represent only the “top-level” groups (GroupLevel = 0 ). Therefore, if you want to get other group levels, you will need to go through each group’s (CollectionViewGroup) Items collection, which contains both child CollectionViewGroups and the group’s data items (their type will depend on the data source,), check their type, and continue recursing if you find a child CollectionViewGroup.

    You can take a look at the “Selecting all items in a group” example in the documentation to help you get started.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 4739 views)

    User (Old forums)
    Member
    Post count: 23064
                    <xcdg:TableView>
                        <xcdg:TableView.GroupLevelConfigurations>
    ¬†¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†<xcdg:GroupLevelConfiguration InitiallyExpanded=”False”>
                            </xcdg:GroupLevelConfiguration>
                        </xcdg:TableView.GroupLevelConfigurations>
     
    when I use the above XAML, I am getting the below error ::  
     
                    <xcdg:TableView>
                        <xcdg:TableView.GroupLevelConfigurations>
    ¬†¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†<xcdg:GroupLevelConfiguration InitiallyExpanded=”False”>
                            </xcdg:GroupLevelConfiguration>
                        </xcdg:TableView.GroupLevelConfigurations> 

    Imported from legacy forums. Posted by Koti (had 479 views)

    Xceed Support
    Member
    Post count: 5658

    The GroupLevelConfigurations property has been obsolete since version 3.0, is this the error  message you are receiving?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1083 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.