.NET MAUI DataForm Grouping
Telerik UI for .NET MAUI DataForm supports grouping. You can define the groups directly in the DataForm or using the GroupName
DisplayAttribute
in the business model.
The Grouping is part of Telerik UI for .NET MAUI, the most comprehensive UI suite for .NET MAUI! To try it out, sign up for a free 30-day trial and kickstart your cross-platform app development today.
The
GroupName
(string
) property is the identifier for each group.
Define Groups in XAML and Add Editors to the Group
You can organize the Editors in groups using the DataFormGroup
(Telerik.Maui.controls.DataFormItem
).
DataForm definition with Grouping applied:
Note that local
in the snippet above points to the namespace where the EditorsViewModel
is defined.
And the business model used:
Use GroupName Display Attribute in the model
Apply grouping using the GroupName
display attribute. More information about this can be found in the Microsoft documentation.
Example with GroupName
display attribute applied in the business model.
1. Define the model for the RadDataForm
:
2. Define the RadDataForm
in XAML:
Note that model
in the snippet above points to the namespace where the GroupingModel
is defined.
Define the Groups in XAML and GroupName in the Model
You can apply the groups in the XAML and set the GroupName
property. Then inside the model add the GroupName
attribute to the concrete property.
1. DataForm XAML definition with grouping applied:
Note that model
in the snippet above points to the namespace where the GroupingModel
is defined.
2. Add the GroupName
display attribute to the properties in the ViewModel
:
For a runnable example with the DataForm Grouping scenarios, see the SDKBrowser Demo Application and go to DataForm > Grouping category.
Events
Telerik .NET MAUI DataForm exposes an event for group generation:
-
GroupGenerated
—Raised when the data form is about to generate a group of items automatically. This event can be used to customize the automatic generation of groups in the data form, when theTelerik.Maui.Controls.RadDataForm.AutoGenerateItems
property istrue
and group is not specified explicitly for the given category in theTelerik.Maui.Controls.RadDataForm.Items
collection. It's possible to customize, replace or discard the generated group, before is added to the DataForm. TheGroupGenerated
event handler receives two parameters:-
sender
argument which is of type object, but can be cast to theRadDataForm
type. -
DataFormGroupGeneratedEventArgs
which has a reference to theGroupName
(string
)—Gets the unique name of the group to generate,Group
(DataFormGroup
)—Specifies the group, which is generated for the specified unique name. To skip the generation of the group, set this property to null.
-
And the handler:
For a runnable example with the DataForm CustomGenerate scenario, see the SDKBrowser Demo Application and go to DataForm > Getting Started category.