This is a migrated thread and some comments may be shown as answers.

Default a filter on load

1 Answer 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 08 Mar 2016, 01:03 PM

Hello,

I am supporting a legacy app which uses RadGridView from version 2014.1.224.1050 of Telerik.Windows.Controls.dll. I cannot update the version of Telerik I am using for this project at the moment. The Grid has filtering enabled

Many of the data sources for the grid have an IsEnabled boolean field. On the initial load, the user would like to filter out all the records where IsEnabled is false, my preferred way of doing this would be to check the Is Enabled = true option in the filter and apply this automatically, but I cannot find a way to do this.

Approaches I have tried have been adding a FilterDescriptor, but this would only add the Filter options for the True value. Some googling suggested using FilterExpression on the MasterGridView, but when I try and add this as XAML, the parser reports an error. Is that functionality not available in the version of silver light I am using?

 

Can anyone suggest a way to check a filter option and run it on load?

 

Best Regards

David

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 09 Mar 2016, 04:17 PM
Hello David,

I would suggest  taking a look at our article regarding Programmatic Filtering if you have not done so already.

To help you out, I've attached a sample project demonstrating the desired behavior.
Could you please have a look at it and let me know whether it suits your needs?

Here's the code that I've used:

public MainPage()
        {
            InitializeComponent();
            FilterIsEnabledColumn();
        }

private void FilterIsEnabledColumn()
        {
            Telerik.Windows.Controls.GridViewColumn isEnabledColumn = this.clubsGrid.Columns["IsEnabled"];
            IColumnFilterDescriptor isEnabledFilter = isEnabledColumn.ColumnFilterDescriptor;
 
            isEnabledFilter.SuspendNotifications();
 
            isEnabledFilter.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsEqualTo;
            isEnabledFilter.FieldFilter.Filter1.Value = "true";
            isEnabledFilter.FieldFilter.Filter1.IsCaseSensitive = false;
 
            isEnabledFilter.ResumeNotifications();
        }

I hope you find this helpful.

Regards,
Dilyan Traykov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or