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

Filter RadGrid Programmatically

11 Answers 1804 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vamshi
Top achievements
Rank 1
Vamshi asked on 27 Jan 2012, 06:27 PM
Hi,

I am trying to filter a radgrid from code behind. I have come across two approaches. The first one doesn't work and the second does.

1. This doesnt show the filtered results. It shows all rows. HOwever when I look in the filter control of this column it seems to have set it.

GridColumn
rowStateColumn = rgvFlightsEdit.MasterTableView.GetColumnSafe("RowState");
rowStateColumn.CurrentFilterFunction = GridKnownFunction.NotEqualTo;
rowStateColumn.CurrentFilterValue = "Existing";

rgvFlightsEdit.Rebind();

2. This works:

rgvFlightsEdit.MasterTableView.FilterExpression =
"([RowState] LIKE '%Existing%')";
rgvFlightsEdit.Rebind();

I would prefer the 1st option because it seems to give a little bit more control on the filter function. If I can't get it to work and have to use the second option, where can I find the allowable filter expressions i.e. what else can I use besided 'LIKE'?

Thanks!

11 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jan 2012, 07:37 AM
Hello,

Try setting AutoPostBackOnFilter as true.

-Shinu.
0
Elliott
Top achievements
Rank 2
answered on 30 Jan 2012, 04:00 PM
I know for a fact that FilterExpression of [UniqueName]='value' works
if you need anything else set the filter on any column and look in the CommandWindow in a debugging session for the FilterExpression
0
Vamshi
Top achievements
Rank 1
answered on 30 Jan 2012, 05:37 PM
It is already on server-side, per se, because I am trying to set the filtering on server side. Having said that, I did try setting the 'AutoPostBackOnFilter=true' for that column and I still get the same results i.e. the grid doesn't display the filtered rows even though the filter condition and value show on the column.
Any other suggestions?
0
Vamshi
Top achievements
Rank 1
answered on 30 Jan 2012, 05:39 PM
Hi Marianne, yes I do see the Filter expression and value in debug mode. Moreover, I also see the 'value' in the filter control of that column in the UI and also the 'condition' when I click on the 'funnel' icon. It all seems to be correct except the grid is still displaying all the rows.
0
Elliott
Top achievements
Rank 2
answered on 30 Jan 2012, 05:55 PM
I misunderstood your problem - I thought you were asking how do I code a Contains filter, for instance
your problem is - why doesn't my filter "take"
it may be with the way your Ajax manager is coded
in what event are you hanging your filtering code on?
0
Vamshi
Top achievements
Rank 1
answered on 30 Jan 2012, 06:23 PM
I have a radcombobox and a 'Go' button. Based on user selection in that combobox, the grid is supposed to get filtered and 'unfiltered'.
0
Elliott
Top achievements
Rank 2
answered on 30 Jan 2012, 06:34 PM
I have three RadComboBoxes all set to post back
on any selection that changes I adjust the filter based on the newly selected item, then rebind
it's a bit of string manipulation
the format seems to be [UniqueName] operator value AND ...
it looks like Telerik routines look at FilterExpression to determine filtering and not the column's CurrentFilter Function and Value
0
WaspDeveloper
Top achievements
Rank 1
answered on 07 May 2013, 05:33 PM
I am having this same problem. Was a solution ever found?
0
Eyup
Telerik team
answered on 10 May 2013, 10:18 AM
Hi Chris,

You can fire a filter command to apply a filter to any given column both on client and server side:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-filter.html
http://www.telerik.com/help/aspnet-ajax/grid-fire-command-event-from-code.html

Hope this helps.

All the best,
Eyup
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.
0
Best
Top achievements
Rank 1
answered on 29 Jul 2013, 08:21 PM
Hi Vamshi
Did you find any solution for your problem, because i have the same?
and unfortunately this:
RadGrid.MasterTableView.FilterExpression = "([ColumeUniqueName] = " + ViewState("ID") + ")"
RadGrid.Rebind()
is not working :(
0
Eyup
Telerik team
answered on 01 Aug 2013, 10:14 AM
Hello,

You can use the ItemCommand event handler to prevent the initial filtering and build the filtering expression manually according to your own requirements:
http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html

Here is a similar sample:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/multi-selection-radcombobox-for-filtering-grid.aspx

Hope this helps.

Regards,
Eyup
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Vamshi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Elliott
Top achievements
Rank 2
Vamshi
Top achievements
Rank 1
WaspDeveloper
Top achievements
Rank 1
Eyup
Telerik team
Best
Top achievements
Rank 1
Share this question
or