Skip to main content

TreeList.CustomRowFilter Event

Allows you to specify the node visibility, regardless of the applied filter.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.2.dll

Declaration

[DXCategory("Behavior")]
public event CustomRowFilterEventHandler CustomRowFilter

Event Data

The CustomRowFilter event's data class is CustomRowFilterEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets whether the event is handled and no default processing is required. Inherited from FilterNodeEventArgs.
IsFitDefaultFilter Gets whether the row matches the filter applied to the tree list. Inherited from FilterNodeEventArgs.
Item[TreeListColumn] Gets a value of a specific column in the processed TreeListNode.
Node Gets the currently processed node. Inherited from FilterNodeEventArgs.
Row Gets an object representing a data row in the underlying data source that corresponds to the processed TreeListNode.
Visible Gets whether the processed TreeListNode is visible.

Remarks

When the Tree List filters data, it iterates through nodes according to its filter mode (TreeList.OptionsFilter.FilterMode), and it can skip specific nodes.

The TreeList raises the CustomRowFilter event according to the filter mode. Depending on the filter mode, the CustomRowFilter event may occur not for all nodes, and sometimes in a different order. For example, in ParentsMatch filter mode, the TreeList skips child nodes if a parent node does not match the current filter. The CustomRowFilter event does not fire for skipped nodes.

‘Matches’ and ‘Smart’ Filter Modes

In Matches and Smart filter modes (see TreeList.OptionsFilter.FilterMode), a collapsed node’s children are hidden even if they match the current filter. The CustomRowFilter event fires for collapsed children. These nodes, however, remain hidden even if you set the Visible event parameter to true. Enable the TreeListOptionsFilter.ExpandNodesOnFiltering option to automatically expand collapsed nodes before filtration.

Example

The example below ensures that Tree List records with the 15% discount are always visible, regardless of the currently applied filtering condition.

TreeList - Custom Filter

private void TreeList1_CustomRowFilter(object sender, CustomRowFilterEventArgs e) {
    TreeList treeList = sender as TreeList;
    string discount = treeList.GetRowCellDisplayText(e.Node, treeList.Columns["Discount"]);
    if (discount == "15%") {
        e.Visible = true;
        e.Handled = true;
    }
}
See Also