Treeview Child Sort Order
Hi all!
Does anyone have a way to quickly sort the Treeview child nodes of a Parent, say, in alphanumeric order?
Example:
Parent 1 - State
|____Texas
|____Alabama
|____New York
Kind regards,
Jason
SIGN IN To post a reply.
9 Replies
1 reply marked as answer
SP
Sowmiya Padmanaban
Syncfusion Team
November 26, 2020 12:36 PM UTC
Hi Jason,
Greetings from Syncfusion support.
In TreeView component, we have sortOrder property. Using this property, you can sort the TreeView nodes in ascending and descending order based on your requirement.
Please, refer the below code snippet.
|
<SfTreeView @ref="tree" TValue="MailItem" SortOrder="SortOrder.Ascending">
<TreeViewFieldsSettings TValue="MailItem" Id="Id" DataSource="@MyFolder" Text="FolderName" ParentID="ParentId" HasChildren="HasSubFolders" Expanded="Expanded"></TreeViewFieldsSettings>
</SfTreeView> |
Please, refer the below sample link: https://www.syncfusion.com/downloads/support/forum/160038/ze/TreeView-755850040.zip
Please, refer to the below links to know more about the TreeView component.
UG Documentation- https://blazor.syncfusion.com/documentation/treeview/data-binding/#self-referential-data
API reference- https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfTreeView-1.html
Please let us know, if you need any further assistance.
Regards,
Sowmiya.P
Marked as answer
JA
Jason
November 26, 2020 10:44 PM UTC
It works perfectly, thank you!!!
SP
Sowmiya Padmanaban
Syncfusion Team
November 27, 2020 04:28 AM UTC
Hi Jason,
We are happy to hear that your problem has been resolved. Please contact us, if you need any help from us.
Regards,
Sowmiya.P
BA
BAx
April 7, 2021 09:38 PM UTC
Is there a way to sort by a different property than the alphabetic content of the node?
Thanks
SP
Sowmiya Padmanaban
Syncfusion Team
April 8, 2021 11:53 AM UTC
Hi BAx,
Currently, we don’t have any direct property to sort the TreeView node based on a different property other than alphabetic content. To achieve your requirement, you need to manually sort the nodes based on your requirement and assign the sorted data to the TreeView dataSource.
This will re-render the TreeView component with sorted data.
Please let us know, if you need any further assistance.
Regards,
Sowmiya.P
BA
BAx
April 8, 2021 02:41 PM UTC
Ok so if I do not define the SortOrder in the TreeView the items order will reflect exactly the order in which they are provided?
KR
Keerthana Rajendran
Syncfusion Team
April 9, 2021 05:14 AM UTC
Hi BAx,
The default value of SortOrder property is none which will update the TreeView node order based on the order of items in DataSource. As mentioned earlier, you can assign the manually sorted data as dataSource without assigning SortOrder property in your code.
Regards,
Keerthana.
BA
BAx
April 9, 2021 12:54 PM UTC
Perfect, thank you
KR
Keerthana Rajendran
Syncfusion Team
April 12, 2021 05:03 AM UTC
Hi BAx,
Most welcome. We are glad that the provided suggestion helped you. Please get back to us if you need further assistance.
Regards,
Keerthana.
SIGN IN To post a reply.