Helpers in WinUI TreeGrid (SfTreeGrid)

13 Apr 20211 minute to read

IndexResolver

SfTreeGrid has TreeGridIndexResolver static class present in the Syncfusion.UI.Xaml.TreeGrid namespace has some extension methods to resolve from row or column index to node or visible column index and vice-versa.

For example, you can get a node from its row index using the GetNodeAtRowIndex method.

treeGrid.GetNodeAtRowIndex(3);

Prototype table

Prototype

Description

ResolveToNodeIndex(int rowIndex) Resolves the node index from the row index. When row index does not find any record, it returns -1. The NodeIndex denotes the index of node in SfTreeGrid.View.Nodes.
ResolveToRowIndex(int nodeIndex) Resolves the row index from the node index associated with SfTreeGrid.View.Nodes. When node index is lesser than 0 it returns -1.
ResolveToRowIndex(object data) Resolves the row index from the data associated with SfTreeGrid.View.Nodes. When the given node is not available in the collection, it returns -1.
ResolveToRowIndex(TreeNode node) Resolves the row index from the node associated with SfTreeGrid.View.Nodes. When the given node is not available in the collection, it returns -1.
ResolveToGridVisibleColumnIndex(int columnIndex) Resolves the TreeGridColumn index from the visible column index. It excludes row header and indent column.
ResolveToScrollColumnIndex(int gridColumnIndex) Resolves column index from the grid column index associated with SfTreeGrid.Columns. It also includes the indent column and row header also.
ResolveToStartColumnIndex() Returns the start column index of the VisibleColumn.
GetHeaderIndex() Returns the header row index.
GetNodeAtRowIndex(int rowIndex) Gets the tree node based on the row index.

Dispose

This method is associated with relinquishes memory and clears all references associated with treegrid. When you call this method, it releases all references for treegrid. So, the memory occupied using treegrid is reclaimed. You should call the SfTreeGrid.Dispose method to release the memory.