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

filter grid with a text box text

10 Answers 642 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mahsa boreiry
Top achievements
Rank 1
mahsa boreiry asked on 26 Dec 2010, 06:37 AM
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.

10 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 26 Dec 2010, 08:11 PM
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
0
mahsa boreiry
Top achievements
Rank 1
answered on 26 Dec 2010, 08:38 PM
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.
0
Emanuel Varga
Top achievements
Rank 1
answered on 26 Dec 2010, 08:54 PM
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
0
mahsa boreiry
Top achievements
Rank 1
answered on 26 Dec 2010, 09:07 PM
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?

0
Emanuel Varga
Top achievements
Rank 1
answered on 26 Dec 2010, 09:15 PM
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
0
mahsa boreiry
Top achievements
Rank 1
answered on 26 Dec 2010, 09:23 PM
I use  "Telerik 2010 Q1 SP1"  not  Q3.
it does'nt supportfilterDescriptor ??
0
Jack
Telerik team
answered on 28 Dec 2010, 10:24 AM
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.
0
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
answered on 21 Jan 2011, 08:36 AM
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.
0
Jack
Telerik team
answered on 26 Jan 2011, 11:23 AM
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.
0
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
answered on 26 Jan 2011, 11:39 AM
Yup. I enable Filtering and had to show the Filter Row to get the desired results.
Tags
GridView
Asked by
mahsa boreiry
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
mahsa boreiry
Top achievements
Rank 1
Jack
Telerik team
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or