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

Server side remove filter

2 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ahmed Ilyas
Top achievements
Rank 1
Ahmed Ilyas asked on 10 Apr 2012, 11:22 AM
How is it possible to remove a filter from server side? For example I need to use combined filtering of columns.
if we have 5 columns and we filter 3 of them initially, this is fine however if the user changes the filter for one of the columns, the filter expression is incorrect (understandbly why because I am concatinating the existing expression along with the new one)

is there a way to remove a specific filter and then apply the new filter?

If (String.IsNullOrEmpty(Me.grdShiftObservation.MasterTableView.FilterExpression)) Then
   Me.grdShiftObservation.MasterTableView.FilterExpression = dtFromString
Else
   Me.grdShiftObservation.MasterTableView.FilterExpression =  Me.grdShiftObservation.MasterTableView.FilterExpression & " AND " & dtFromString
end if


so the initial expression maybe "DateTime >= #...#"
Then if the user selects a different filter then the expression will be:

"DateTime >= #...# AND DateTime <= #...#"

which is not what I want. In this case it would be DateTime <= #...#

so I just want to remove from the FilterExpression the related column filter completely

2 Answers, 1 is accepted

Sort by
0
Ahmed Ilyas
Top achievements
Rank 1
answered on 10 Apr 2012, 12:08 PM
From the behavior I am seeing (combination of server side and ajax filtering), I believe I can just forget about doing the filter concatination and just set the filter expression to the filter I want and that seems to work and the client side filters it correctly too with any other filters being applied.

update: actually forget that. I was wrong. not sure whats going on or how it really works. I see in our solution, which I am taking over and working with, that both AJAX and server filtering are taking place. So its hard to get the correct filter expression to be built for a custom server filter.
All I want is to remove a filter that already possibly exists (server side) from the FilterExpression
0
Tsvetina
Telerik team
answered on 16 Apr 2012, 06:34 AM
Hello Ahmed,

When using custom filter expressions, you need to take care of creating, adding and clearing it manually, as RadGrid cannot handle it itself. I am attaching a sample project showing one way to do this. You can see that the last column is filtered by a list of comma-separated values. I keep the custom filter in ViewState, so I can remove it when needed.
I hope this helps.

Regards,
Tsvetina
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
Ahmed Ilyas
Top achievements
Rank 1
Answers by
Ahmed Ilyas
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or