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

[Solved] Combining search and column filter on grid using filterexpression.

3 Answers 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joakim Nilsson
Top achievements
Rank 1
Joakim Nilsson asked on 06 Jan 2010, 02:09 PM
Hi,

I am in need of some help with filtering on my radgrid.

I have a textbox outside of the grid that alters the grid.mastertableview.filterexpression and a filter on one of the columns in the grid that also alters the filterexpression. This setup is used to combine the two "filters" into one filter.

To create the columnfilter I use the following example: http://www.telerik.com/help/aspnet-ajax/grdfilteringwithdropdownlist.html

In the Itemcommand = "Filter" I set the the mastertableview.filterexpression but when debugging the page I see that setting the filterexpession there does no difference as it seems to change again before rendering the grid.

The search-textbox works correctly by altering the filterexpression and rebinding the grid when event OnTextChanged is triggered.

The columnfilter is altering the filteringexpression on its own somewhere without telling me. ;) Does anyone have any idea where this happens? I dont see any need of attaching code as I have followed the example above almost exactly.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 07 Jan 2010, 09:20 AM
Hi Joakim,

It is hard to say what is causing this problem without seeing some code. Could you please open a support ticket and provide a sample app that recreates this problem or post some sample of your code here to the forums. We will check it and do our best to help.

Also could you try to set a FilterExpression on the MasterTableView in the RadGrid1_PreRender event handler  and see if the issue still persist:

protected void RadGrid1_PreRender(object sender, System.EventArgs e)
{
   if(CommandFilterFlag )
   {
     RadGrid1.MasterTableView.FilterExpression = "Filter Expression"
     GridColumn column = 
        RadGrid1.MasterTableView.GetColumnSafe("ColumnUniqueName");
     column.CurrentFilterFunction = GridKnownFunction.Contains;
     column.CurrentFilterValue = "FilterValue";
     RadGrid1.Rebind();
   }
}
 
public bool CommandFilterFlag { get; set; }
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
 if (e.CommandName == "Filter")
 {
     CommandFilterFlag = true;
 }
}

I hope this helps.

All the best,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Joakim Nilsson
Top achievements
Rank 1
answered on 07 Jan 2010, 09:34 AM
The problem was solved using the prerender event.

Thank you for your help!
0
Robert Bergbrant
Top achievements
Rank 1
answered on 19 Mar 2010, 03:59 PM
I have on initial page load set currentfiltervalue on each column to specific values. After that I bind my grid to a objectdatasource.

My problem is that I am unable to make a filter event with my currentfilter values on each column, without touching filterexpression.

I Would like to, on server side or client side, just rebind my mastertable or grid without having to set the filterexpression manually.

this is my aproach so far on the page load event:

      For i As Integer = 0 To SessionFilter.Count - 1
        Dim p As Pair = SessionFilter(i)
        RadGrid1.MasterTableView.GetColumnSafe(p.First).CurrentFilterFunction = GridKnownFunction.StartsWith
        RadGrid1.MasterTableView.GetColumnSafe(p.First).CurrentFilterValue = p.Second
      Next
      RadGrid1.Rebind()
Tags
Grid
Asked by
Joakim Nilsson
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Joakim Nilsson
Top achievements
Rank 1
Robert Bergbrant
Top achievements
Rank 1
Share this question
or