How to change the editors order in the group of .NET MAUI DataForm (SfDataForm)?
The Syncfusion® .NET MAUI DataForm (SfDataForm) enables grouping and ordering editors using properties and events. This article provides a guide on how to change the order of editors within groups.
With Attributes:
You can change the editor order either by using the Order property of the Display attribute or by using the RowOrder property of the DataFormDisplayOptions attribute.
Now, you can see the example for changing the order of the editors in the group with the help of the Order property with the GroupName property in the Display attribute. You can use the Order property in the Display attribute or the RowOrder property in the DataFormDisplayOptions attribute to change editor order within a group.
C#:
public class DataFormModel { [Display(GroupName = "General Information", Order = 1, Prompt = "Enter your last name")] public string LastName { get; set; } [Display(GroupName = "General Information", Order = 3)] public Gender Gender { get; set; } [Display(GroupName = "General Information", Order = 0, Prompt = "Enter your first name")] public string FirstName { get; set; } }
Here, the example for changing the order of the editors in the group with the help of the RowOrder property within the DataFormDisplayOptions attribute is provided.
C#:
public class DataFormModel { [Display(GroupName = "Educational Information")] [DataFormDisplayOptions(RowOrder = 2)] public DateTime GraduationDate { get; set; } [Display(GroupName = "Educational Information", Prompt = "Enter your degree")] [DataFormDisplayOptions(RowOrder = 0)] public string Degree { get; set; } [Display(GroupName = "Educational Information")] [DataFormDisplayOptions(RowOrder = 1)] public string Branch { get; set; } }
With Event:
You can also change the editor order with the help of the RowOrder property of a DataFormItem in the GenerateDataFormItem event.
C#:
private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e) { if (e.DataFormItem != null) { if (e.DataFormItem.FieldName == "LastName") { e.DataFormItem.RowOrder = 1; } else if (e.DataFormItem.FieldName == "Gender") { e.DataFormItem.RowOrder = 2; } else if (e.DataFormItem.FieldName == "FirstName") { e.DataFormItem.RowOrder = 0; } else if (e.DataFormItem.FieldName == "GraduationDate") { e.DataFormItem.RowOrder = 2; } else if (e.DataFormItem.FieldName == "Degree") { e.DataFormItem.RowOrder = 0; } else if (e.DataFormItem.FieldName == "Branch") { e.DataFormItem.RowOrder = 1; } } }
Download the complete sample on GitHub
Output:
Conclusion:
I hope you enjoyed learning how to change the editor’s order in the group within the .NET MAUI DataForm (SfDataForm).
You can refer to our .NET MAUI DataForm feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataForm documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI DataForm and other .NET MAUI components.
Please let us know in the comment section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!