how can i get the filter text in the NeedDataSource event in a RadGrid with custom paging

1.6k Views Asked by At

I am using custom paging in a RadGrid. It is working fine. But filter is not working as i want. So I thought of writing my own code for filter. But how could i get the filter text and the coloumn for which the filter was applied in the NeedDataSource event.

2

There are 2 best solutions below

0
On BEST ANSWER

I got the answer, but I forgot to update here. My bad...

The answer is: gridObject.MasterTableView.FilterExpression. This grid property has all the filters concatenated as a string. this string contains column headers and the filter applied separated by comma ,. You can split that and work on it.

0
On

I found another way, which I discovered thanks to ckr's answer here. You need to do this for each filterable column you are interested in:

var filterValue = rgFilterPoints.MasterTableView.GetColumn("YourColumnName").CurrentFilterValue;

Another option, if you happen to be in an event whose EventArgs parameter has Item (like GridCommandEventArgs), you can use this:

((GridTableCell)e.Item.Cells[5]).Column.CurrentFilterValue

You need to use column index in this case. Beware there are a few "hidden" columns at the beginning, so in this example I'm accessing the 4th column in the markup.