DxTreeList.FilterBy(String, TreeListFilterRowOperatorType, Object) Method
Filters TreeList data by the specified column value.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public void FilterBy(
string columnFieldName,
TreeListFilterRowOperatorType operatorType,
object value
)
Parameters
| Name | Type | Description |
|---|---|---|
| columnFieldName | String | Specifies the name of the data source field that supplies data for the processed column. If the component does not contain the column that corresponds to the specified data field, an exception occurs. |
| operatorType | TreeListFilterRowOperatorType | An enumeration value. |
| value | Object | Specifies a filter value. |
Remarks
The FilterBy method allows you to filter TreeList data by an individual column’s value. The filter row displays the specified filter value in the corresponding column’s editor. The method call replaces an existing filter value (if any) for the column.
You can use the column’s FilterRowValue and FilterRowOperatorType properties to specify the initial value in a column’s filter row editor.
The highlighted code block adds a button that filter TreeList data by the Task column’s values:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
ShowFilterRow="true"
@ref="MyTreeList">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
<DxButton Click="@(() => MyTreeList.FilterBy("Name", TreeListFilterRowOperatorType.Contains, "Update"))">
Filter By "Task"
</DxButton>
@code {
ITreeList MyTreeList { get; set; }
List<EmployeeTask> TreeListData { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
}
You can also use the FilterBy method to clear the filter condition in code. To do this, pass null to the method’s value parameter.
<DxButton Click="@(() => MyTreeList.FilterBy("Name", TreeListFilterRowOperatorType.Contains, null))">Clear the "Task" Filter Condition</DxButton>
To clear all filter conditions in code, call the ClearFilter() method.
For more information, see the following topic: Filter Row in Blazor TreeList.