Problem setting a default filter for the grid

3 posts, 1 answers
  1. Jacob
    Jacob  avatar
    49 posts
    Member since:
    Apr 2016

    Posted 17 Nov 2016 Link to this post

    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. Jacob
    Jacob  avatar
    49 posts
    Member since:
    Apr 2016

    Posted 21 Nov 2016 in reply to Jacob Link to this post

    Please update me on this as soon as possible. thank you
  3. Answer
    Dilyan Traykov
    Dilyan Traykov avatar
    1194 posts

    Posted 21 Nov 2016 Link to this post

    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.

    Dilyan Traykov
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top