Default a filter on load

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Jul 2015

    Posted 08 Mar Link to this post

    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

  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 09 Mar Link to this post

    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
  3. DevCraft banner
Back to Top