Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeView.CustomFilter Property

Allows you to implement custom filter logic.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public Func<ITreeViewNodeInfo, bool> CustomFilter { get; set; }

#Property Value

Type Description
Func<ITreeViewNodeInfo, Boolean>

A method defined by the Func<ITreeViewNodeInfo, bool> signature.

#Remarks

The CustomFilter property allows you to replace the default filter behavior.

The following code maps month names (June, July, and August) with the word Summer:

razor
<DxTreeView ShowFilterPanel="true"
            CustomFilter="@((n) => IsSummer(n.Text))"
            @bind-FilterString=@FilterString
            FilterMode="NavigationFilterMode.Nodes"
            CssClass="cw-480"
            Data="@DataSource"
            LoadChildNodesOnDemand="true"
            @ref=@treeView>
    <DataMappings>
        <DxTreeViewDataMapping HasChildren="HasSubGroups"
                               Children="SubGroups"
                               Text="Title" />
    </DataMappings>
</DxTreeView>

@code {
    string FilterString = "";
    bool IsSummer(string Text) {
        if (FilterString == "Summer" && (Text.Contains("June") || Text.Contains("July") || Text.Contains("August")))
            return true;
        else
            return false;
    }
    DxTreeView treeView;
    @* ... *@
}

Custom Filter

Note that you should also implement custom highlight logic if required. Use the NodeTextTemplate property to do so. Refer to our GitHub example for implementation details.

View Example: Implement Custom Filter

See Also