TreeListOperation.NeedsFullIteration Property
Gets a value indicating whether all or only parent nodes must be processed by the operation.
Namespace: DevExpress.XtraTreeList.Nodes.Operations
Assembly: DevExpress.XtraTreeList.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList
Declaration
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool NeedsFullIteration { get; }
Property Value
Type | Description |
---|---|
Boolean | true if all nodes must be processed by the operation; false if only nodes that have children are to be processed. |
Remarks
There may be situations when you need to traverse only through nodes that have child rows. This can be used if the information provided by the parent node about its children is enough to perform the desired operation. For instance, you can calculate the sum of all nodes within the control in such a manner. Instead of incrementing a counter each time a node is visited, you can visit only the parent nodes and accumulate their child nodes count. Another example can be using the iterator to expand or collapse all nodes. You don’t need to process nodes that don’t have children in this case either.
As implemented in the TreeListOperation class, the NeedsFullIteration property simply returns true. If you don’t want to process nodes that don’t have children, override this property in your TreeListOperation descendant.
Note: Not all the parent nodes are visited if the NeedsFullIteration property is set to false. The nodes for which the TreeListOperation.NeedsVisitChildren method returns false are omitted.
Example
The following sample code declares the TreeListCustomCountOperation operation class. It can be used to calculate the number of nodes whose parent contains the value of “Monterey” in its Location field.
The operation is performed by calling the TreeListNodesIterator.DoOperation method. Its result is stored to the result variable.
public class TreeListCustomCountOperation : TreeListOperation {
private int count;
public TreeListCustomCountOperation() {
count = 0;
}
// the parent node's Location field must contain the Monterey value
public override bool NeedsVisitChildren(TreeListNode node) {
return node["Location"].ToString() == "Monterey";
}
// only parent nodes must be visited
public override bool NeedsFullIteration {
get { return false; }
}
public override void Execute(TreeListNode node) {
count += node.Nodes.Count;
}
public int Count {
get { return count; }
}
}
//...
// performing the operation and storing its result
TreeListCustomCountOperation operation = new TreeListCustomCountOperation();
treeList1.NodesIterator.DoOperation(operation);
int result = operation.Count;