GridView Filters Case Sensitive

17 posts, 0 answers
  1. Matt
    Matt avatar
    3 posts
    Member since:
    Oct 2011

    Posted 19 Dec 2011 Link to this post

    I would like to turn off the case sensitive filters in the WinForm GridView.  I've found a few CaseSensitive flags and have set them to  false  but the grid filters are remaining case sensitive.  Here is an example of what I tried:

    dataTable.Rows.Clear();
    dataTable.BeginLoadData();
       ((logic for adding rows to the data table is here))
    dataTable.CaseSensitive = false;
    dataTable.EndLoadData();

    radGridView.MasterTemplate.BeginUpdate();
    radGridView.MasterTemplate.CaseSensitive = false;
    radGridView.DataSource = dataTable;
    radGridView.GridBehavior.GridControl.CaseSensitive = false;
    radGridView.MasterTemplate.EndUpdate();

    I am using the following Telerik library:
        WinForms Q3 2011 (version 2011.3.11.1116)

    Can you please explain how to turn off case sensitivity for the filters in your WinForm grid control?

    Can you also provide the class paths for all the CaseSensitivity flags?
      e.g. 1) radGridView.MasterTemplate.CaseSensitive
             2) radGridView.GridBehavior.GridControl.CaseSensitive
             3) etc...

    Thanks so much!
    Scott

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 21 Dec 2011 Link to this post

    Hello Matt,

    Thank you for writing.

    The property that you need to work with in order to modify the case sensitivity of RadGridView is the CaseSensitive property of the desired template. So if you have only one level of data you can set this property of the control, alternatively you need to set it to every child template. Here is a sample code for flat grid, which will demonstrate how this property works. 
    GridViewTextBoxColumn col = new GridViewTextBoxColumn();
    radGridView1.Columns.Add(col);
    col.Width = 200;
    radGridView1.Rows.Add("Jim");
    radGridView1.Rows.Add("jim");
     
    radGridView1.EnableFiltering = true;
    radGridView1.MasterTemplate.CaseSensitive = true;

    I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.

    All the best,
    Stefan
    the Telerik team

    Q3’11
    of RadControls for WinForms is available for download (see what's new). Get it today.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 24 Feb 2015 Link to this post

    Hi Stefan,

    I want to filter RadGrid InSensitive mode, how can I achieve this ?
    Thank for future helps.
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Feb 2015 Link to this post

    Hi Cevdet,

    As I mentioned in my previous post, to enable case sensitive filtering of the grid, you need to set the CaseSensitive property:
    radGridView1.MasterTemplate.CaseSensitive = true;

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 25 Feb 2015 Link to this post

    Hi again,

    I mean, It is not working when I try to filter turkish characters "ı,i,ö,ü,ş,ç,ğ,I,İ,Ö,Ü,Ş,Ç,Ğ" in RadGrid.
    For exammple :
    Record => Kitap,  Filter => İ  (İ is uppercase)
    Record => KİTAP, Filter => i (i is lowercase)

    Tnaks
  7. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 25 Feb 2015 Link to this post

    If I change RadGrid CultureInfo, the problem will be solved ?
    If so, how can I change CultureInfo of Radgrid ?
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2015 Link to this post

    Hi Cevdet,

    I have tested this with the examples you provided and seems to be working just fine on my end. Attached you can find a video (opens in browser) of the process.

    The culture I have is en-US (Thread.CurrentThread.CurrentUICulture).

    What is the culture you have?

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 26 Feb 2015 Link to this post

    Hi,

    My culture is tr-TR,
    How can I reach the video ?

    Thanks for response.
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2015 Link to this post

    Hi,

    I have tested with "tr-TR" and I get the same behavior.

    Let me try to attach the video once again to this post, as it seems it did not appear in the previous one.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2015 Link to this post

    It seems we currently have some issue with the attachments - already looking into it. 

    I have uploaded the video here for you.
  12. Cevdet
    Cevdet avatar
    1 posts
    Member since:
    Feb 2015

    Posted 04 Mar 2015 in reply to Stefan Link to this post

    Hi Stefan again,

    I downloaded video but can't see clearly, please send me a piece of your code or whole demo project ?

    Thanks.
  13. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Mar 2015 Link to this post

    Hello,

    The project is what you can see on the video. I have attached it to this post for your convenience.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  14. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 05 Mar 2015 in reply to Stefan Link to this post

    Hi,

    I run the project that you attached but I mean :
    When I click filter1 or filter2 button, I want to see two record (Kitap and KİTAP) on RadGridView.

    How can I do that ?
    Thanks.
  15. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 06 Mar 2015 Link to this post

    Hello,

    Thank you for the clarification. 

    The comparison we perform during the filtering uses InvariantCulture, hence it is culture-insensitive. What I can offer for your case is to use Custom Filtering. Here is a small example:
    public partial class Form1 : Form
        {
            RadGridView radGridView1 = new RadGridView();
            CultureInfo cultureInfo = new CultureInfo("tr-TR");
     
            public Form1()
            {
                InitializeComponent();
     
                this.Controls.Add(radGridView1);
                radGridView1.Size = new System.Drawing.Size(300, 300);
     
                radGridView1.Columns.Add("column1");
                radGridView1.Columns[0].Width = 100;
                radGridView1.Rows.Add("Kitap");
                radGridView1.Rows.Add("KİTAP");
     
                radGridView1.EnableFiltering = true;
                radGridView1.EnableCustomFiltering = true;
                radGridView1.CustomFiltering += radGridView1_CustomFiltering;
            }
     
            void radGridView1_CustomFiltering(object sender, GridViewCustomFilteringEventArgs e)
            {
                if (radGridView1.FilterDescriptors.Count == 0)
                {
                    return;
                }
     
                foreach (var item in radGridView1.FilterDescriptors)
                {
                    string cellValue = e.Row.Cells[item.PropertyName].Value.ToString();
     
                    if (item.Operator == Telerik.WinControls.Data.FilterOperator.Contains)
                    {
                        e.Visible = cultureInfo.CompareInfo.IndexOf(cellValue, item.Value.ToString(), CompareOptions.IgnoreCase) > -1;
                    }
                }
                 
                if (e.Visible)
                {
                    e.Handled = true;
                }
            }
     
            private void button1_Click(object sender, EventArgs e)
            {
                radGridView1.FilterDescriptors.Clear();
                radGridView1.FilterDescriptors.Add(new FilterDescriptor("column1", FilterOperator.Contains, "İ") { IsFilterEditor = true });
            }
        }

    I hope that you find it useful.
     
    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  16. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 06 Mar 2015 in reply to Stefan Link to this post

    Thank you Stefan,
    It worked fine for contains filter.
    How can we change code for all filters (starts with, ends with, not contains, contains, etc...) ?

    Thanks.
  17. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 06 Mar 2015 Link to this post

    You will just have to extend the code I gave you with if statements for every operator you want:
    if (item.Operator == Telerik.WinControls.Data.FilterOperator.X)
    {
         //perform your custom filtering
    }

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  18. cevdet
    cevdet avatar
    19 posts
    Member since:
    Jan 2015

    Posted 06 Mar 2015 in reply to Stefan Link to this post

    Ok Stefan thanks a lot.

    Regards.
Back to Top
UI for WinForms is Visual Studio 2017 Ready