Back to Devexpress

DxTreeView.CustomFilter Property

blazor-devexpress-dot-blazor-dot-dxtreeview-2ced5b7a.md

latest2.3 KB
Original Source

DxTreeView.CustomFilter Property

Allows you to implement custom filter logic.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

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

Property Value

TypeDescription
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;
    @* ... *@
}

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

DxTreeView Class

DxTreeView Members

DevExpress.Blazor Namespace