Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
365
Apply/Reset Filter in runtime
posted

Hello,

I'm using xamDataGrid to display some info. Each row has a boolean field named IsActive. My task to add a checkbox under the grid 'Hide inactive items' to allow user manage his information. If checkbox is checked I need to apply filter and if unchecked I need to reset it.

I've tried the following code in checkbox checkedchanged event handler but it doesn't work -

private void CheckBox_Checked(object sender, RoutedEventArgs e)

{

    var isChecked = ((CheckBox)sender).IsChecked == true;

    if (isChecked)

    {

        var filter = new RecordFilter();

        filter.FieldName = "IS_ACTIVE";

        filter.Conditions.Add(new ComparisonCondition(ComparisonOperator.Equals, true));

        _grid.FieldLayouts[0].RecordFilters.Add(filter);

    }

    else

    {

        _grid.FieldLayouts[0].RecordFilters.Clear();

    }

}

Could you please advise the best solution for my case?