Class TreeGridView
The class which has the functionalities of node management and sorting.
Namespace: Syncfusion.Maui.TreeGrid
Assembly: Syncfusion.Maui.TreeGrid.dll
Syntax
public class TreeGridView : Object, ITreeGridViewNotifier, IDisposable
Constructors
TreeGridView(SfTreeGrid)
Initialize a new instance of the TreeGridView class.
Declaration
public TreeGridView(SfTreeGrid treeGrid)
Parameters
| Type | Name | Description |
|---|---|---|
| SfTreeGrid | treeGrid |
TreeGridView(IEnumerable, SfTreeGrid, Type)
Initializes a new instance of TreeGridView class.
Declaration
public TreeGridView(IEnumerable source, SfTreeGrid treeGrid, Type sourceType = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IEnumerable | source | The source collection. |
| SfTreeGrid | treeGrid | An instance of SfTreeGrid |
| System.Type | sourceType | The source type. |
Fields
IsDisposed
flag which indicates whether view is disposed or not.
Declaration
protected bool IsDisposed
Field Value
| Type |
|---|
| System.Boolean |
IsInEndeferal
Gets a value indicating whether this instance is in end defer.
Declaration
protected bool IsInEndeferal
Field Value
| Type | Description |
|---|---|
| System.Boolean | true if this instance is in end defer; otherwise, false. |
IsInSuspend
Denotes whether data manipulation operation is suspended or not.
Declaration
protected bool IsInSuspend
Field Value
| Type |
|---|
| System.Boolean |
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 |
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 |
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 |
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 PropertyDescriptorCollection ItemProperties { get; }
Property Value
| Type | Description |
|---|---|
| System.ComponentModel.PropertyDescriptorCollection | The item properties. |
NewItemPlaceholderPosition
Gets or sets the NewItemPlaceholderPosition.
Declaration
public NewItemPlaceholderPosition NewItemPlaceholderPosition { get; set; }
Property Value
| Type |
|---|
| NewItemPlaceholderPosition |
Nodes
Gets the collection of
Declaration
public TreeNodeCollection Nodes { get; }
Property Value
| Type |
|---|
| TreeNodeCollection |
Records
Gets a flat collection of records (nodes) for column-sizing calculations. Iterates the tree recursively and exposes each visible node so the column sizer can measure cell widths.
Declaration
public IReadOnlyList<TreeNode> Records { get; }
Property Value
| Type |
|---|
| System.Collections.Generic.IReadOnlyList<TreeNode> |
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.
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 |
CancelNew()
Ends the add transaction and discards the pending new item.
Declaration
public void CancelNew()
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 |
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
Declaration
public void Dispose()
Dispose(Boolean)
Disposes all the resources used by the
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. |
EndInit()
Resumes the data operations and reinitialize the view.
Declaration
public void EndInit()
GetItemProperties()
Declaration
public virtual PropertyDescriptorCollection GetItemProperties()
Returns
| Type |
|---|
| System.ComponentModel.PropertyDescriptorCollection |
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 . |
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. |
RaiseNodeCollectionChangedEvent(NotifyCollectionChangedEventArgs)
Raises the node collection changed event.
Declaration
protected void RaiseNodeCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Specialized.NotifyCollectionChangedEventArgs | args | NotifyCollectionChangedEventArgs. |
RaisePropertyChanged(String)
Raises the PropertyChanged event.
Declaration
protected void RaisePropertyChanged(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyName | propertyName. |
Refresh()
Recreates the view.
Declaration
public void Refresh()
RefreshFilter()
Refreshes the view when the filtering is applied through
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()
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
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 |