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

Problem setting a default filter for the grid

2 Answers 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 17 Nov 2016, 05:13 PM

Hello Telerik,

 

I have carefully read the examples you provided here and this one in particular seems to be the one I need

[C#] Example 4: A custom FilterDescriptor
// Give me all people that are with first name John.
var fd = new FilterDescriptor();
fd.Member = "FirstName";
fd.Operator = FilterOperator.IsEqualTo;
fd.Value = "John";
fd.IsCaseSensitive = true;
 
// In most cases the data engine will discover this automatically so you do not need to set it.
fd.MemberType = typeof(string);

 

It works. The grid starts filtered as expected, however it is not possible for the user to revert that initial filter.

Is there anything missing? I tried to find a running example for those filterdescriptors, but i couldn't. If there is one, can you please provide it?

 

Thank you!

2 Answers, 1 is accepted

Sort by
0
Jacob
Top achievements
Rank 1
answered on 21 Nov 2016, 04:25 PM
Please update me on this as soon as possible. thank you
0
Accepted
Dilyan Traykov
Telerik team
answered on 21 Nov 2016, 04:29 PM
Hello Jacob,

As stated in the aforementioned article, if you need the filtering criteria you've defined to be reflected in RadGridView's UI (and thus later clearable by the user), you need to use the IColumnFilterDescriptor contract. You can obtain such a descriptor for a given column by accessing its ColumnFilterDescriptor property. You can then modify it as suggested here.

var fd = this.radGridView.Columns["FirstName"].ColumnFilterDescriptor;
fd.FieldFilter.Filter1.Operator = FilterOperator.IsEqualTo;
fd.FieldFilter.Filter1.Value = "John";
fd.FieldFilter.Filter1.IsCaseSensitive = true;

I hope you find this information helpful. Do let me know if you need any further assistance on the matter.

Regards,
Dilyan Traykov
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
Jacob
Top achievements
Rank 1
Answers by
Jacob
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or