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.Value Property

Returns the FilterString value.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public string Value { get; }

#Property Value

Type Description
String

The FilterString value.

#Remarks

Use the Value property to access the DxTreeView.FilterString or DxAccordion.FilterString value.

The following example uses the Value property to get the DxTreeView.FilterString value and divide this string by a comma:

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>;
   }
}

TreeView - Split the node text

View Example: Implement Custom Filter

See Also