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

Radgridview's filter icon and data doesn't get updated programmatically

2 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Naresh Kapse
Top achievements
Rank 1
Naresh Kapse asked on 01 Apr 2010, 05:44 PM
Hi,

When I set the filters on the RadGridView programmatic-ally, the icon of the filtered column doesn't update itself. (Even the filtered column doesn't show the filtered data).

In the following code,        

The "Country" column get filtered but will not update the icon. The filter pop-up doesn't contain the filtered data.

Is there any way, how we could achieve this.

using System.Windows.Controls;  
using Telerik.Windows.Controls;  
using Telerik.Windows.Data;  
  
namespace Ticket226810  
{  
    public partial class Page : UserControl  
    {  
        public Page()  
        {  
            InitializeComponent();  
  
            playersGrid.ItemsSource = Club.GetPlayers();  //some data is assigned to the grid
        }  
  
        void OnEnglishOnlyUnchecked(object sender, System.Windows.RoutedEventArgs e)  
        {  
            this.playersGrid.FilterDescriptors.Clear();  
        }  
  
        void OnEnglishOnlyChecked(object sender, System.Windows.RoutedEventArgs e)  
        { 

           // The "Country" column get filtered but will not update the icon. The filter pop-up doesn't contain the filtered data.
            this.playersGrid.FilterDescriptors.Add(new FilterDescriptor("Country", FilterOperator.IsEqualTo, "England"));  
        }  
    }  
}  
  


Thanks,
Kapser.

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 02 Apr 2010, 01:49 PM
Hi Naresh Kapse,

There is a way to do this. Let me explain.

The way you have done it does not work because RadGridView cannot detect which column exactly do you want to filter. There may be many columns that are bound to the same field.

In case you want to filter the grid as though you are filtering it from the UI, you will have to add a special descendant of the FilterDescriptor class called ColumnFilterDescriptor. This class is the same as FilterDescriptor but it knows which column to filter and the grid will respect it.

I have prepared an extensive tutorial on how to do this here.

Let me know if there are problems or questions.

All the best,
Ross
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Naresh Kapse
Top achievements
Rank 1
answered on 05 Apr 2010, 02:30 PM
Hey Ross,

Thanks for the solution. It worked.
Tags
GridView
Asked by
Naresh Kapse
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Naresh Kapse
Top achievements
Rank 1
Share this question
or