I want to show only specific set of filters in the Radzen DataGrid. For example, I want to hide "Is null" and "Is not null" from the filter operators set. Or, broader question, I want to specify my custom set of filter operators for each type. Any possibility?
It can be done through inheriting from the RadzenDataGridColumn and overriding its GetFilterOperators method, as shown in the Radzen tutorial (check "MyCustomDataGridColumn.razor" tab). I'll just copy the example code from there, adding only a little changings:
@using Radzen
@typeparam TItem
@inherits RadzenDataGridColumn<TItem>
@code {
public override IEnumerable<FilterOperator> GetFilterOperators()
{
var operators = base.GetFilterOperators();
if (FilterPropertyType == typeof(DateTime?))
{
operators =
operators.Where(o => o != FilterOperator.IsNull && o != FilterOperator.IsNotNull);
// or using patterns
// operators =
// operators.Where(o => o is not (FilterOperator.IsNull or FilterOperator.IsNotNull);
}
return operators;
}
public override bool ShowTimeForDateTimeFilter()
{
return false;
}
}