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

Get selected filter menu value

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 15 May 2012, 04:34 PM
I need to know how to get to the selected value of the filter menu. For example if the user selects "Contains" from the menu, I need to know where to get to the value "Contains".

When I try to get it from column.CurrentFilterFunction, I get an empty string. I was assuming that the CurrentFilterFunction property was what I was looking for, but I guess not.

Is there a way to get this value programmatically?

Thanks,
Eric

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 May 2012, 05:05 AM
Hello Eric,

Try accessing the filter menu in ItemCommand event as shown below.
C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.FilterCommandName)
 {
   Pair filterPair = (Pair)e.CommandArgument;
   string value = filterPair.First.ToString();
 }
}

Thanks,
Shinu.
0
Eric
Top achievements
Rank 1
answered on 16 May 2012, 02:21 PM
Thank you for your reply, Shinu. I should have mentioned that I had already explored that, but during that event, the filters come through one at a time, which does not work for our needs.

I am trying to loop through the columns and extract it that way to aggregate the filters and associated values, to build a custom where clause for a stored procedure. I'm trying to avoid working with the FilterExpression manually.

Any idea how to best attack this situation - my first time with the RadGrid.

Thanks,
Eric
0
Antonio Stoilkov
Telerik team
answered on 18 May 2012, 08:27 AM
Hi Eric,

You could achieve your scenario by subscribing to RadGrid PreRender event and access the MasterTableView FilterExpression there and implementing your logic. You could take a look at the help articles below for more information on the topic.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Eric
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or