DxTreeList.DataColumnFilterRowCellTemplate Property
Allows you to replace automatically generated editors with custom content in all filter row cells displayed for data columns.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public RenderFragment<TreeListDataColumnFilterRowCellTemplateContext> DataColumnFilterRowCellTemplate { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment<TreeListDataColumnFilterRowCellTemplateContext> | Template content. |
Remarks
Enable the ShowFilterRow option to activate a row that allows users to filter data. The filter row displays automatically generated in-place editors for all data columns. Editor types depend on data types of the corresponding column fields. You can customize settings of automatically generated editors, hide them, or replace them with other editors.
Place one or more editors in a column’s FilterRowCellTemplate to display custom content in the filter row cell. To define a custom template for all cells, define the TreeList’s DataColumnFilterRowCellTemplate
. Both templates include the context parameter that has the following properties:
- DataColumn
- Allows you to access the processed column.
- TreeList
- Allows you to access the TreeList and its extensive API.
- FilterCriteria
- Allows you to apply filter criteria to the column.
- FilterRowValue
- Allows you to bind an editor value to a filter row value. Note that the editor should have a nullable value type.
Note
The TreeList does not render automatically generated editors in filter row cells if you define DataColumnFilterRowCellTemplate
.
The following code snippet defines a common template for all filter row cells:
@inject SpaceObjectDataProvider SpaceObjectDataProvider
<DxTreeList Data="TreeListData" ChildrenFieldName="Satellites" ShowFilterRow="true">
<Columns>
<DxTreeListDataColumn FieldName="Name" />
<DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
<DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2" FilterRowOperatorType="TreeListFilterRowOperatorType.LessOrEqual">
<HeaderCaptionTemplate>Mass, 10<sup>21</sup> × kg</HeaderCaptionTemplate>
</DxTreeListDataColumn>
<DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2" FilterRowOperatorType="TreeListFilterRowOperatorType.LessOrEqual" />
<DxTreeListDataColumn FieldName="Volume10pow9KM3" DisplayFormat="N2" FilterRowOperatorType="TreeListFilterRowOperatorType.LessOrEqual">
<HeaderCaptionTemplate>Volume, 10<sup>9</sup> × km<sup>3</sup></HeaderCaptionTemplate>
</DxTreeListDataColumn>
<DxTreeListDataColumn FieldName="SurfaceGravity" DisplayFormat="N2" FilterRowOperatorType="TreeListFilterRowOperatorType.LessOrEqual">
<HeaderCaptionTemplate>Gravity, m/s<sup>2</sup></HeaderCaptionTemplate>
</DxTreeListDataColumn>
</Columns>
<DataColumnFilterRowCellTemplate>
@if (context.DataColumn.FieldName == "Name" || context.DataColumn.FieldName == "TypeOfObject") {
<DxTextBox Text="@((string?)context.FilterRowValue)"
TextChanged="(string? v) => context.FilterRowValue = v"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto">
</DxTextBox>
}
else {
<DxSpinEdit Value="(double?)context.FilterRowValue"
ValueChanged="(double? v) => context.FilterRowValue = v"
ShowSpinButtons="false"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto">
<Buttons>
<DxEditorButton IconCssClass="editor-icon editor-icon-caret-left"
Tooltip="Decrement by 10"
Position="@EditorButtonPosition.Left"
Click="() => OnIncrementButtonClick(context, false)" />
<DxEditorButton IconCssClass="editor-icon editor-icon-caret-right"
Tooltip="Increment by 10"
Click="() => OnIncrementButtonClick(context, true)" />
</Buttons>
</DxSpinEdit>
}
</DataColumnFilterRowCellTemplate>
</DxTreeList>
@code {
object TreeListData { get; set; }
protected override async Task OnInitializedAsync() {
TreeListData = SpaceObjectDataProvider.GenerateData();
}
void OnIncrementButtonClick(TreeListDataColumnFilterRowCellTemplateContext context, bool isIncrementButton) {
var oldValue = context.FilterRowValue != null ? (double)context.FilterRowValue : 0;
context.FilterRowValue = oldValue + (isIncrementButton ? 10 : -10);
}
}
For more information about templates in the TreeList component, refer to the following topic: Templates in Blazor TreeList.