Blazor Hierarchical Grid Collapsible Column Groups Overview
The Ignite UI for Blazor Collapsible Column Groups feature in Blazor Hierarchical Grid allows you to organize and manage multiple levels of nested columns and column groups in the IgbHierarchicalGrid
by grouping them together and providing the option to collapse or expand these groups for improved data visualization and navigation.
Blazor Hierarchical Grid Collapsible Column Groups Example
Like this sample? Get access to our complete Ignite UI for Blazor toolkit and start building your own apps in minutes. Download it for free.
Setup
To get started with the IgbHierarchicalGrid
and the Collapsible multi-column headers feature, first you need to install Ignite UI for Blazor by typing the following command:
> dotnet add package IgniteUI.Blazor --version 24.2.71
cmd
For a complete introduction to the Ignite UI for Blazor, read the getting started topic.
Also, we strongly suggest that you take a brief look at multi-column headers topic, to see more detailed information on how to setup the column groups in your grid.
Usage
Collapsible Column Groups is a part of the multi-column headers feature which provides a way to collapse/expand a column group to a smaller set of data. When a column group is collapsed, a subset of the columns will be shown to the end-user and the other child columns of the group will hide. Each collapsed/expanded column can be bound to the grid data source, or it may be unbound, thus calculated.
In order to define a column group as collapsible, you need to set the Collapsible
property on the IgbColumnGroup
to true.
You need to define the property VisibleWhenCollapsed
to at least two child columns. At least one column must be visible when the group is collapsed (VisibleWhenCollapsed
set to true) and at least one column must be hidden when the group is expanded (VisibleWhenCollapsed
set to false
), otherwise the collapsible functionality will be disabled. If VisibleWhenCollapsed
is not specified for some of the child columns, then this column will be always visible regardless of whether the parent state is expanded or collapsed.
Let's see the markup below:
<IgbColumnGroup Header="Customer Information" Collapsible="true">
<!--The column below will be visible when its parent is collapsed-->
<IgbColumn Field="CustomerName" Header="Full name" VisibleWhenCollapsed="true"></IgbColumn>
<!--The three columns below will be visible when its parent is expanded-->
<IgbColumn Field="CustomerID" Header="Customer ID" VisibleWhenCollapsed="false"></IgbColumn>
<IgbColumn Field="FirstName" Header="First Name" VisibleWhenCollapsed="false"></IgbColumn>
<IgbColumn Field="LastName" Header="Last Name" VisibleWhenCollapsed="false"></IgbColumn>
<IgbColumnGroup Header="Customer Address">
<IgbColumn Field="Country" Header="Country" Sortable="true"></IgbColumn>
<IgbColumn Field="City" Header="City" Sortable="true"></IgbColumn>
</IgbColumnGroup>
</IgbColumnGroup>
razor
To summarize, every child column has three states:
- Can be always visible, no matter the expanded state of its parent.
- Can be visible, when its parent is collapsed.
- Can be hidden, when its parent is collapsed.
The initial state of the column group which is specified as collapsible is Expanded
set to true, but you can easily change this behavior by setting it to false.
Note Please keep in mind that initially collapse group option takes precedence over column hidden - If you declared your column to be hidden using the property hidden and you have a group defined where the same column should be shown, the column will be shown.
API References
Additional Resources
Our community is active and always welcoming to new ideas.