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

How to set filters to column programmatically?

5 Answers 386 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 1
Anton asked on 16 Jan 2013, 07:04 AM
I've found this article: http://www.telerik.com/help/wpf/gridview-filtering-programmatic.html
But column doesn't have "ColumnFilterDescriptor" property. I use 2011.3.1220.40 version of controls.

My problem:
I want to set filters to auto-generated column. I can set filters to grid using "grid.FilterDescriptors" property. It filters data in grid but when I open filter in column header it resets. How to set filters to column?

P.S. My code for adding filter to grid:
grid.FilterDescriptors[i] = new ColumnFilterDescriptor(newColumn)
{
    FilterDescriptors = oldColumnDescriptor.FilterDescriptors,
    LogicalOperator = oldColumnDescriptor.LogicalOperator,
    Column = newColumn
};

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 16 Jan 2013, 08:41 AM
Hello,

Indeed, we introduced those changes with the 2012 Q1. As you use an older version, I can suggest you to check the Breaking Changes described in this article where you can see the "Before" code that you can use in your case. Does this help you or do you have any further questions?

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Anton
Top achievements
Rank 1
answered on 16 Jan 2013, 10:30 AM
It helps to understand that I don't know how to solve my initial problem :(
0
Rossen Hristov
Telerik team
answered on 16 Jan 2013, 11:04 AM
Hi,

Attach to RadGridView's AutoGeneratingColumn event and then in the event handler you will have e.Column.ColumnFilterDescriptor which is used for programmatic filtering as described here.

Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Anton
Top achievements
Rank 1
answered on 16 Jan 2013, 11:12 AM
e.Column doesn't have ColumnFilterDescriptor in my version of telerik controls, so I create new descriptor and add to grid filters. But it doesn't work as I want.

My problem:

1. User load data from server
2. User filter data locally
3. User load data from server
4. New data should apply to filters but don't replace filters, just renew DistinctFilter values.  <- How to realize it?
0
Accepted
Dimitrina
Telerik team
answered on 16 Jan 2013, 03:54 PM
Hi,

Actually the DistinctFilter values should be renewed automatically after the source values change.

With the old version you can add a ColumnFilterDescriptor with a code similar to the following one (for example):

Telerik.Windows.Controls.GridViewColumn nameColumn = this.clubsGrid.Columns[0];
ColumnFilterDescriptor nameColumnFilter = new ColumnFilterDescriptor((IDataFieldDescriptor)nameColumn);
nameColumnFilter.FieldFilter.Filter1.Operator = FilterOperator.Contains;
nameColumnFilter.FieldFilter.Filter1.Value = "Ars";
 
clubsGrid.FilterDescriptors.Add(nameColumnFilter);
 
Still I would suggest you to upgrade.
Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Anton
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Anton
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or