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

NavigationFilterInfo.IsApplied Property

Returns whether the filter is applied.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public bool IsApplied { get; }

#Property Value

Type Description
Boolean

true if the filter is applied; otherwise, false.

#Remarks

The following example uses the IsApplied property value to determine whether to apply custom highlighting:

razor
@page "/"
@using TreeViewCustomFilter.Data
@using System.Text.RegularExpressions;

<DxTreeView Data="@OfficeLocation.Offices"
            @bind-FilterString=FilterString
            ShowFilterPanel="true"
            CustomFilter=@CustomFilter>
    <NodeTextTemplate>
        <span>
            @Template(context)
        </span>
    </NodeTextTemplate>
    <DataMappings>
        <DxTreeViewDataMapping Key="Id" ParentKey="ParentId" Text="Name" />
    </DataMappings>
</DxTreeView>

@code {
   static IEnumerable<string> SplitByComma(string value) => value
           .Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
   string? FilterString { get; set; }
   bool CustomFilter(ITreeViewNodeInfo info) {
       return SplitByComma(info.FilterInfo.Value)
           .Any(word => info.Text.Contains(word, StringComparison.InvariantCultureIgnoreCase));
   }
   RenderFragment Template(ITreeViewNodeInfo info) {
       if(!info.FilterInfo.IsApplied)
           return @<text>@info.Text</text>;
       var words = SplitByComma(info.FilterInfo.Value);
       var pattern = $"(" + string.Join(")|(", words) + ")";
       var matched = Regex.Split(info.Text, pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
       return
           @<text>
               @foreach(var m in matched) {
                   @if(Regex.IsMatch(m, pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) {
                       <span class="dxbl-filter-content">@m</span>
                   }
                   else { @m }
               }
           </text>;
   }
}

Custom filter is applied

View Example: Implement Custom Filter

See Also