How to set default of filterdescriptor.operator

10 posts, 0 answers
  1. kenghot
    kenghot avatar
    31 posts
    Member since:
    Feb 2007

    Posted 05 Jan 2012 Link to this post

    Radgridview's columns have default filter operation as "Contains :" .  How can i change them to "Start with".

    Best Regards,
    Kenghot
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 06 Jan 2012 Link to this post

    Hello,

    Thank you for writing.

    Please refer to the following code snippet, which demonstrates how to set the default filter operator for the first column in the grid:
    radGridView1.Columns[0].FilterDescriptor = new Telerik.WinControls.Data.FilterDescriptor(null, Telerik.WinControls.Data.FilterOperator.StartsWith, null);

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
     
    Greetings,
    Stefan
    the Telerik team

    SP1
    of Q3’11 of RadControls for WinForms is available for download (see what's new).
  3. UI for WinForms is Visual Studio 2017 Ready
  4. kenghot
    kenghot avatar
    31 posts
    Member since:
    Feb 2007

    Posted 08 Jan 2012 Link to this post

    Hi Stefan,
    Your code works. Thanks
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 11 Jan 2012 Link to this post

    Hi, 

    I am glad that I could help. If there is anything else we can assist you with, do not hesitate to contact us.
     
    All the best,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  6. Dumi
    Dumi avatar
    3 posts
    Member since:
    Sep 2016

    Posted 08 Sep Link to this post

    Hi,

    This doesn't seem to work with nullable columns. In my case I have a decimal? field and if when I'm trying to do what you suggested here, the non-null values are filtered out. Any ideas?

     

    Thanks.

  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 09 Sep Link to this post

    Hello Dumi,

    Thank you for writing.

    Please note that the StartsWith operator is not commonly used with GridViewDecimalColumn and that is why it cannot be added from the UI. However, following the described in the thread approach it can be added programmatically.

    The null values are filtered out and this is a desired behavior in this kind of setup. With filtering, you would be able to add custom logic for the null values: http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
  8. Dumi
    Dumi avatar
    3 posts
    Member since:
    Sep 2016

    Posted 13 Sep in reply to Hristo Merdjanov Link to this post

    Hi Hristo,

    Maybe I didn't make myself clear enough in my previous post. I'll try a better description of my issue.

    I have 2 fields in a grid, one is decimal, one is decimal?. For both I’m setting the filter option in the design view to “Equal” - img1.

    When I start the application, the decimal ones has the filter ok, but the decimal? filter is changed to “No filter” - img2

    If I try the workaround from here, it works, but not as I would expect. The filter is applied for the null value and all my decimal? values that are not null are hidden. What I need is just to have the default filter option set to “Equal”, with no filter applied at all.

    Thanks,
    Dumi.
  9. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 16 Sep Link to this post

    Hi Dumi,

    Thank you for writing back.

    The empty text you have will be filtered out when you apply the IsEqualTo operator to the decimal column and this is expected. As stated in my previous post you need to enable custom filtering and handle the filter operation with respect to the null values and leave them visible: http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
  10. Dumi
    Dumi avatar
    3 posts
    Member since:
    Sep 2016

    Posted 19 Sep Link to this post

    I understand what you're saying, I'm already using custom filtering in some of my grids. But what I don't understand is the different behavior of the grid view based on the data type for a column. I don't want to apply a filter, I just want the default filter option to be IsEqualTo. Why does it work for decimal, but not for decimal? ? In my opinion this is an issue of the grid...

    Thanks,
    Dumi.

  11. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 19 Sep Link to this post

    Hi Dumi,

    The default filter operators are determined according to the data type of the column. Since you are having a nullable decimal field, the engine assigns the FilterOperator.None as default.

    As discussed previously in the thread you can add an empty filter having the IsEqualTo operator. In case you keep experiencing issues please open up a support ticket and send us your project so that we can further investigate it.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready