Unplanned
Last Updated: 05 Nov 2024 13:35 by Martin Ivanov
Martin Ivanov
Created on: 05 Nov 2024 13:35
Category: GridView
Type: Bug Report
0
GridView: The Clear Filters option in the FilterRow filtering mode cannot be selected when default operator is set in the FilterOperatorsLoading event

The Clear Filters option in the FieldFilterControl cannot be selected when the DefaultOperator1 is set in the FilterOperatorsLoading event of RadGridView. The FieldFilterControl is the element shown under the column header when the FilteringMode property of RadGridView is set to FilterRow. Setting e.DefaulteOperator1 in the FilterOperatorsLoading properly selects the corresponding filter in the drop down, but after that you cannot select Clear Filters when clicking on this option.

To work this around, you can use the CellLoaded event instead of FilterOperatorsLoading. This will allow you to get the FieldFilterControlViewModel and set its SelectedOperatorViewModel property.

private void manualGridView_CellLoaded(object sender, CellEventArgs e)
{
    if (e.Cell is GridViewHeaderCell && e.Cell.Column.UniqueName == "MyColumn")
    {
        Dispatcher.BeginInvoke(new Action(() =>
        {
            var fieldFilter = e.Cell.FindChildByType<FieldFilterControl>();
            var viewModel = (FieldFilterControlViewModel)fieldFilter.DataContext;
            viewModel.SelectedOperatorViewModel = viewModel.AvailableOperatorViewModels.FirstOrDefault(x => x.FilterOperator == FilterOperator.IsLessThan);
        }));
    }
}

0 comments