Class TreeGridView
The class which has the functionalities of node management and sorting.
Namespace: Syncfusion.UI.Xaml.TreeGrid
Assembly: Syncfusion.Grid.WinUI.dll
Syntax
public class TreeGridView : Object, ITreeGridViewNotifier, IEditableCollectionView, IDisposable
Constructors
TreeGridView()
Initialize a new instance of the TreeGridView class.
Declaration
public TreeGridView()
TreeGridView(IEnumerable)
Initializes a new instance of TreeGridView class.
Declaration
public TreeGridView(IEnumerable source)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | source | The source collection. |
Properties
CanAddNew
Gets a value that indicates whether a new item can be added to the collection.
Declaration
public bool CanAddNew { get; }
Property Value
Type |
---|
System.Boolean |
CanCancelEdit
Gets a value that indicates whether the collection view can discard pending changes and restore the original values of an edited object.
Declaration
public bool CanCancelEdit { get; }
Property Value
Type |
---|
System.Boolean |
CanRemove
Gets a value that indicates whether an item can be removed from the collection.
Declaration
public bool CanRemove { get; }
Property Value
Type |
---|
System.Boolean |
CurrentAddItem
Gets the item that is being added during the current add transaction.
Declaration
public object CurrentAddItem { get; }
Property Value
Type |
---|
System.Object |
CurrentEditItem
Gets the item in the collection that is being edited.
Declaration
public object CurrentEditItem { get; }
Property Value
Type | Description |
---|---|
System.Object | The item in the collection that is being edited if IsEditingItem is true; otherwise, null. |
CurrentItem
Gets the current item in the view.
Declaration
public object CurrentItem { get; }
Property Value
Type | Description |
---|---|
System.Object | The current item of the view or null if there is no current item. |
CurrentPosition
Gets the original position of the CurrentItem within the (optionally sorted) view.
Declaration
public int CurrentPosition { get; }
Property Value
Type |
---|
System.Int32 |
EnableRecursiveChecking
Gets or sets a value which specifies whether recursive node checking is enabled or not. If recursive node checking enabled, node check box state will be changed based on its child or parent check box state.
Declaration
public bool EnableRecursiveChecking { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is False. |
Filter
Gets or sets the func to apply custom filter on source programmatically.
Declaration
public Predicate<object> Filter { get; set; }
Property Value
Type |
---|
System.Predicate<System.Object> |
IsAddingNew
Gets a value indicating whether an add transaction is in progress.
Declaration
public bool IsAddingNew { get; }
Property Value
Type |
---|
System.Boolean |
IsCurrentInSync
Gets a value that indicates whether the CurrentItem is at the CurrentPosition.
Declaration
protected bool IsCurrentInSync { get; }
Property Value
Type |
---|
System.Boolean |
IsEditingItem
Gets a value that indicates whether an edit transaction is in progress.
Declaration
public bool IsEditingItem { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if an edit transaction is in progress; otherwise, false. |
IsInDeferRefresh
Gets a value which indicates whether view is in DeferRefresh.
Declaration
public bool IsInDeferRefresh { get; }
Property Value
Type |
---|
System.Boolean |
ItemProperties
Gets the item properties.
Declaration
public PropertyInfoCollection ItemProperties { get; }
Property Value
Type | Description |
---|---|
PropertyInfoCollection | The item properties. |
LiveNodeUpdateMode
Gets or sets the LiveNodeUpdateMode to control data manipulation operations during data updates.
Declaration
public LiveNodeUpdateMode LiveNodeUpdateMode { get; set; }
Property Value
Type | Description |
---|---|
LiveNodeUpdateMode | One of the LiveNodeUpdateMode that indicates how data manipulation operations are handled during data updates. The default value is Default. |
NewItemPlaceholderPosition
Gets or sets the NewItemPlaceholderPosition.
Declaration
public NewItemPlaceholderPosition NewItemPlaceholderPosition { get; set; }
Property Value
Type |
---|
NewItemPlaceholderPosition |
Nodes
Gets the collection of TreeNode
Declaration
public TreeNodeCollection Nodes { get; }
Property Value
Type |
---|
TreeNodeCollection |
RecursiveCheckingMode
Gets or sets the value which indicates in which case recursive checking should be applied when EnableRecursiveChecking is
Declaration
public RecursiveCheckingMode RecursiveCheckingMode { get; set; }
Property Value
Type |
---|
RecursiveCheckingMode |
SortComparer
Gets a value which indicates the comparer which is used for sorting.
Declaration
protected IComparer<TreeNode> SortComparer { get; }
Property Value
Type |
---|
System.Collections.Generic.IComparer<TreeNode> |
SortComparers
Gets the collection of comparer to sort the data based on custom logic .
Declaration
public virtual SortComparers SortComparers { get; }
Property Value
Type |
---|
SortComparers |
Remarks
A comparer that are added to SortComparers collection to apply custom Sorting based on the specified column name and sort direction.
SortDescriptions
Gets the collection of SortColumnDescription objects to sort the data programmatically.
Declaration
public virtual SortColumnDescriptions SortDescriptions { get; }
Property Value
Type | Description |
---|---|
SortColumnDescriptions | The collection of SortColumnDescription object to sort the data programmatically.The default value is null. |
SourceCollection
Gets the source collection.
Declaration
public IEnumerable SourceCollection { get; }
Property Value
Type |
---|
System.Collections.IEnumerable |
Methods
AddNew()
Adds a new item to the collection.
Declaration
public object AddNew()
Returns
Type | Description |
---|---|
System.Object | The new item that is added to the collection. |
AddNode(TreeNode, TreeNode, Int32, Int32, Boolean)
Add particular node as child of the parent node in the specified index.
Declaration
public void AddNode(TreeNode parentNode, TreeNode treeNode, int nodeIndex, int sourceIndex = -1, bool needDataShaping = true)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | parentNode | parent node. |
TreeNode | treeNode | node needs to be added as child. |
System.Int32 | nodeIndex | index to insert the node in nodeList. |
System.Int32 | sourceIndex | if AllowDataShaping should not be considered, sourceIndex will be passed. In sourceList, based on sourceIndex item will be inserted. In NodeList, based on nodeIndex, node will be inserted. |
System.Boolean | needDataShaping | specifies whether AllowDataShaping needs to be considered in sorting. |
AddNode(TreeNode, Object, Int32, Boolean)
Add node to parent node from data.
Declaration
protected virtual void AddNode(TreeNode parentNode, object data, int index, bool needDataShaping = true)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | parentNode | parentNode. |
System.Object | data | data. |
System.Int32 | index | Index to insert the node in child nodes collection of the specified parent node. |
System.Boolean | needDataShaping | specifies whether AllowDataShaping needs to be considered in sorting. |
AddNotifyListener(Object)
Add the property changed event to particular record.
Declaration
protected void AddNotifyListener(object record)
Parameters
Type | Name | Description |
---|---|---|
System.Object | record | the record. |
AttachTreeView(Object)
Associates treeGrid in view.
Declaration
public virtual void AttachTreeView(object treeGrid)
Parameters
Type | Name | Description |
---|---|---|
System.Object | treeGrid |
BeginInit(TreeViewRefreshMode)
Suspends the all data operations in View.
Declaration
public void BeginInit(TreeViewRefreshMode refreshMode)
Parameters
Type | Name | Description |
---|---|---|
TreeViewRefreshMode | refreshMode |
CancelEdit()
Ends the edit transaction and, if possible, restores the original value to the item.
Declaration
public void CancelEdit()
CancelNew()
Ends the add transaction and discards the pending new item.
Declaration
public void CancelNew()
CommitEdit()
Ends the edit transaction and saves the pending changes.
Declaration
public virtual void CommitEdit()
CommitNew()
Ends the add transaction and saves the pending new item.
Declaration
public void CommitNew()
CreateItemPropertiesProvider()
Creates the item properties provider. Override this method to have return custom IPropertyAccessProvider and have customizations.
Declaration
protected virtual IPropertyAccessProvider CreateItemPropertiesProvider()
Returns
Type | Description |
---|---|
IPropertyAccessProvider | IPropertyAccessProvider. |
CreateTreeNode(Object, Int32, Boolean, TreeNode, Func<TreeGridView>)
Creates a tree node with the specified item at the specified level with specified state.
Declaration
protected TreeNode CreateTreeNode(object item, int level, bool isExpanded, TreeNode parentNode, Func<TreeGridView> getView)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The item to be presented in the node. |
System.Int32 | level | The Node level |
System.Boolean | isExpanded | Indicates whether node is expanded or not. |
TreeNode | parentNode | The corresponding parent node. |
System.Func<TreeGridView> | getView | The TreeGridView func. |
Returns
Type |
---|
TreeNode |
DeferRefresh(TreeViewRefreshMode)
Enters a defer cycle that you can use to merge changes to the view and delay automatic refresh.
Declaration
public IDisposable DeferRefresh(TreeViewRefreshMode refreshMode)
Parameters
Type | Name | Description |
---|---|---|
TreeViewRefreshMode | refreshMode |
Returns
Type | Description |
---|---|
System.IDisposable | An System.IDisposable object that you can use to dispose of the calling object. |
DetachTreeView()
Detach the grid instance present in the view while disposing the view.
Declaration
public virtual void DetachTreeView()
Dispose()
Disposes all the resources used by the TreeGridView class.
Declaration
public void Dispose()
Dispose(Boolean)
Disposes all the resources used by the TreeGridView class.
Declaration
protected virtual void Dispose(bool isDisposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isDisposing | Indicates whether the call is from Dispose method or from a finalizer. |
EditItem(Object)
Begins an edit transaction of the specified item.
Declaration
public void EditItem(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The item to edit. |
EndEdit()
Ends the edit transaction.
Declaration
public virtual void EndEdit()
EndInit()
Resumes the data operations and reinitialize the view.
Declaration
public void EndInit()
GetItemProperties()
Gets the item properties.
Declaration
public virtual PropertyInfoCollection GetItemProperties()
Returns
Type | Description |
---|---|
PropertyInfoCollection | PropertyInfoCollection. |
GetNodeAt(Int32)
Gets the node at specified index.
Declaration
public virtual TreeNode GetNodeAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Node at this index will be returned |
Returns
Type | Description |
---|---|
TreeNode | Returns the node at specified index |
GetPropertyAccessProvider()
Gets the PropertyAccessProvider.
Declaration
public virtual IPropertyAccessProvider GetPropertyAccessProvider()
Returns
Type | Description |
---|---|
IPropertyAccessProvider | the IPropertyAccessProvider. |
GetSource()
Gets the source collection.
Declaration
protected virtual IEnumerable GetSource()
Returns
Type | Description |
---|---|
System.Collections.IEnumerable | the source collection. |
GetTreeGrid()
Gets treeGrid associated in the view.
Declaration
public virtual object GetTreeGrid()
Returns
Type | Description |
---|---|
System.Object | treeGrid. |
IsChildNodeAvailable(TreeNode)
Checks whether child node will be available for particular tree node.
Declaration
public bool IsChildNodeAvailable(TreeNode treeNode)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | treeNode | the tree node. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the child node will be available; otherwise , false . |
MoveCurrentToPosition(Int32)
Sets the item at the specified index to be the CurrentItem in the view.
Declaration
public virtual bool MoveCurrentToPosition(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index to set the CurrentItem to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the resulting CurrentItem is an item within the view; otherwise, false. |
MoveNode(TreeNode, Int32, Int32)
Moves the child node from an index to the another index in child nodes of particular tree node.
Declaration
protected virtual void MoveNode(TreeNode treeNode, int oldStartingIndex, int newStartingIndex)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | treeNode | tree Node. |
System.Int32 | oldStartingIndex | oldStartingIndex. |
System.Int32 | newStartingIndex | newStartingIndex. |
OnCollectionChanged(Object, NotifyCollectionChangedEventArgs)
Method which handles the collection changes.
Declaration
protected virtual void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | sender. |
System.Collections.Specialized.NotifyCollectionChangedEventArgs | e | NotifyCollectionChangedEventArgs. |
OnRecordPropertyChanged(Object, PropertyChangedEventArgs)
Raises record property changed event.
Declaration
protected virtual void OnRecordPropertyChanged(object sender, PropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | the record. |
System.ComponentModel.PropertyChangedEventArgs | e | the PropertyChangedEventArgs. |
Refresh()
Recreates the view.
Declaration
public void Refresh()
RefreshFilter()
Refreshes the view when the filtering is applied through Filter delegate.
Declaration
public void RefreshFilter()
Remove(Object)
Declaration
public void Remove(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item |
RemoveAt(Int32)
Removes the item at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The specified index. |
RemoveNode(TreeNode, Object)
Remove the data from the child collection of particular tree node.
Declaration
protected virtual void RemoveNode(TreeNode parentNode, object data)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | parentNode | The parent node. this is null if root node needs to be removed. |
System.Object | data | the data. |
RemoveNotifyListener(Object)
Removes the property changed event of particular record.
Declaration
protected void RemoveNotifyListener(object record)
Parameters
Type | Name | Description |
---|---|---|
System.Object | record | the record. |
ReplaceNode(TreeNode, IList, IList, Int32)
Replaces the items at specified index with the new items in child collection of the particular tree node.
Declaration
protected virtual void ReplaceNode(TreeNode treeNode, IList oldItems, IList newItems, int newStartingIndex)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | treeNode | treeNode. |
System.Collections.IList | oldItems | |
System.Collections.IList | newItems | |
System.Int32 | newStartingIndex |
ResetNodes(TreeNode)
Clear the child nodes of the particular node.
Declaration
protected virtual void ResetNodes(TreeNode parentNode)
Parameters
Type | Name | Description |
---|---|---|
TreeNode | parentNode | The Specified parent node. |
Resume()
Resumes the data manipulation operations in SfTreeGrid.
Declaration
public void Resume()
SetCurrent(Object)
Sets the current item of the View.
Declaration
protected virtual void SetCurrent(object newItem)
Parameters
Type | Name | Description |
---|---|---|
System.Object | newItem | The item to set as the CurrentItem. |
SetSource(IEnumerable)
Sets the source collection.
Declaration
protected virtual void SetSource(IEnumerable source)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | source | source. |
Suspend()
Suspends the data manipulation operations in SfTreeGrid.
Declaration
public void Suspend()
UpdateNodesOnPropertyChange(Object, PropertyChangedEventArgs, TreeNode)
Check TreeGridView on property changes and do the actions.
Declaration
protected virtual void UpdateNodesOnPropertyChange(object sender, PropertyChangedEventArgs e, TreeNode treeNode = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | updated record. |
System.ComponentModel.PropertyChangedEventArgs | e | PropertyChangedEventArgs. |
TreeNode | treeNode | Tree node. |
Events
CurrentChanged
Occurs when current item is changed.
Declaration
public event EventHandler<object> CurrentChanged
Event Type
Type |
---|
System.EventHandler<System.Object> |
CurrentChanging
Occurs when current item is being changed.
Declaration
public event CurrentChangingEventHandler CurrentChanging
Event Type
Type |
---|
Microsoft.UI.Xaml.Data.CurrentChangingEventHandler |
NodeCollectionChanged
Occurs when node collection is changed.
Declaration
public event NotifyCollectionChangedEventHandler NodeCollectionChanged
Event Type
Type |
---|
System.Collections.Specialized.NotifyCollectionChangedEventHandler |
PropertyChanged
Occurs when a property value changes.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type |
---|
System.ComponentModel.PropertyChangedEventHandler |
RecordPropertyChanged
Occurs when record property is changed.
Declaration
public event PropertyChangedEventHandler RecordPropertyChanged
Event Type
Type |
---|
System.ComponentModel.PropertyChangedEventHandler |
SourceCollectionChanged
Occurs when source collection is changed.
Declaration
public event NotifyCollectionChangedEventHandler SourceCollectionChanged
Event Type
Type |
---|
System.Collections.Specialized.NotifyCollectionChangedEventHandler |