filter grid with a text box text

11 posts, 1 answers
  1. mahsa boreiry
    mahsa boreiry avatar
    1 posts
    Member since:
    Aug 2009

    Posted 26 Dec 2010 Link to this post

    Hi guys.
     I use win forms . and telerik gridview.
    How can I filter a radgridview with a textbox_keypress. not by radgrid's filter?(while I am typing in textbox, rad grid view data is filter)
     is it possible?
    thnx.
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 26 Dec 2010 Link to this post

    Hello,

    The cleanest way is to declare a private instance variable FilterDescriptor, and on text change just change the value of that variable, like so:
    private FilterDescriptor filterDescriptor;
     
    void radTextBox1_TextChanged(object sender, EventArgs e)
    {
        if (filterDescriptor == null)
        {
            filterDescriptor = new FilterDescriptor("Name", FilterOperator.Contains, radTextBox1.Text);
            radGridView1.FilterDescriptors.Add(filterDescriptor);
        }
        else
        {
            filterDescriptor.Value = radTextBox1.Text;
        }
    }

    Or you could always just remove all of the filters and add a new filter on each key press, like so:
    void radTextBox1_TextChanged(object sender, EventArgs e)
    {
        radGridView1.FilterDescriptors.Clear();
        radGridView1.FilterDescriptors.Add("Name", FilterOperator.Contains, radTextBox1.Text);
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. mahsa boreiry
    mahsa boreiry avatar
    1 posts
    Member since:
    Aug 2009

    Posted 26 Dec 2010 Link to this post

    Thanks alot Emanuel Varga  for your great answer.
    witch namespace I should use for FilterDescriptor ?
    i test " using Telerik.Data;"
    and "using Telerik.WinControls .Data;"
    for =>  private FilterDescriptor filterDescriptor;
    but it dosent work .
    I use telerik 2010 and c# winform.
    thanks alot. again.
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 26 Dec 2010 Link to this post

    Hello again,

    It is under Telerik.WinControls.Data.
    If you have the Grid assemblies loaded it should work, please use the project configuration utility to configure your project, you can easily access it by right clicking on the project -> Rad Controls for WinForms -> Configure Project, and there, check:
    Teleik.WinControls
    Telerik.WinControls.GridView
    Telerik.WinControls.UI
    Telerik.WinControls.Common

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  6. mahsa boreiry
    mahsa boreiry avatar
    1 posts
    Member since:
    Aug 2009

    Posted 26 Dec 2010 Link to this post

    Thanks for trying to help me.
    I check it and have all
    Teleik.WinControls
    Telerik.WinControls.GridView
    Telerik.WinControls.UI
    Telerik.Common

    in Telerik.WinControls.Data I have FilterExpression and FilterPredicate    but no FilterDescriptor.

    where is the problem?

  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 26 Dec 2010 Link to this post

    Hello again,

    Can you please check again the version of telerik controls you are using? As far as i am aware the FilterDescriptor is available in the 2010 release.
    If you cannot update to the latest version (Q3 2010 SP1 although i would strongly recommend it because there were a lot of bugs fixed) i will try to offer you a solution, but please let me know first.

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  8. mahsa boreiry
    mahsa boreiry avatar
    1 posts
    Member since:
    Aug 2009

    Posted 26 Dec 2010 Link to this post

    I use  "Telerik 2010 Q1 SP1"  not  Q3.
    it does'nt supportfilterDescriptor ??
  9. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 28 Dec 2010 Link to this post

    Hi mahsa boreiry,

    The Q2 2010 version of RadControls for WinForms included many new features and in this version we introduced a new data layer for the RadGridView control. This is also the first version where you can find the FilterDescriptor class.

    I recommend that you try our latest release - Q3 2010 SP1.  We will appreciate your feedback regarding it.

    Kind regards, Jack
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  10. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 21 Jan 2011 Link to this post

    Hello. I find this to be a very helpful thread. I'm dealing with a similar situation.

    I have a couple of text boxes and a grid. The thing is that the grid is not filtering.

    private void LoadFilteredActiveClients() {
      RadGridViewSearch.FilterDescriptors.Clear();
     
      if (!String.IsNullOrEmpty(Text_Filter_Name.Text.Trim())) {
        RadGridViewSearch.FilterDescriptors.Add(new FilterDescriptor("Name", FilterOperator.Contains, Text_Filter_Name.Text.Trim()));
      }
     
      if (!String.IsNullOrEmpty(Text_Filter_City.Text.Trim())) {
        RadGridViewSearch.FilterDescriptors.Add(new FilterDescriptor("City", FilterOperator.Contains, Text_Filter_City.Text.Trim()));
      }
     
      if (!String.IsNullOrEmpty(Text_Filter_Phone.Text.Trim())) {
        RadGridViewSearch.FilterDescriptors.Add(new FilterDescriptor("PhoneNumber", FilterOperator.Contains, Text_Filter_Phone.Text.Trim()));
      }
     
      if (!String.IsNullOrEmpty(Text_Filter_Number.Text.Trim())) {
        RadGridViewSearch.FilterDescriptors.Add(new FilterDescriptor("RegisterationNumber", FilterOperator.Contains, Text_Filter_Number.Text.Trim()));
      }
     
      if (!String.IsNullOrEmpty(Text_Filter_PostCode.Text.Trim())) {
        RadGridViewSearch.FilterDescriptors.Add(new FilterDescriptor("Address", FilterOperator.Contains, Text_Filter_PostCode.Text.Trim()));
      }
     
    }

    I don't know why but I have gone through the properties of the grid. The grid is bound through a TableAdaptor. All data is loaded into it on form load. then there are to be no SQL server calls for filtering quires. The grid had hierarchies defined. I just need plain and simple filtering on client side.
  11. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 26 Jan 2011 Link to this post

    Hi Hassan,

    Thank you for your question.

    By default, the filtering is disabled in RadGridView, you have to enable it explicitly by setting the EnableFiltering property to true. Could you please confirm that this is the case? If not, I will need some additional information in order to investigate this issue further. Which is the version of RadControls for Winforms that you are using? Could you please open a new ticket and send us your application where your case is demonstrated?

    I am looking forward to your reply.

    Best wishes, Jack
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  12. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 26 Jan 2011 Link to this post

    Yup. I enable Filtering and had to show the Filter Row to get the desired results.
Back to Top
UI for WinForms is Visual Studio 2017 Ready