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

FilterExpression cleared on sort

4 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 18 Feb 2010, 10:45 PM
I am attempting to implement filtering for the first time using the RadGrid and have run into a problem/question/ignorance and I hope that someone can guide me in the correct direction.  Here is the scenario:

I have a page that loads a grid with filtering by column disabled (set to false).  The grid is using a LinqDataSource on the page and the DataSourceID is set.  The grid works fine for sorting, paging, etc.

The user may click on a button that turns on the filtering for the grid.  At this point the filtering is working great, including adding filters to multiple columns.  However, once a user chooses a non-filtering action that causes a postback, such as a sort or changing the page size, the filter disappears from the data.  The filter textboxes still show the values entered by the user, they are just not applied.

I have found that the FilterExpression on the MasterTableView object is an empty string, but the individual columns are retaining their CurrentFilterValue as the text entered into the filter textbox.

Do I need to manually "migrate" the filters from the columns up to the table level?  If so, at what point in the page/control's life cycle would be appropriate?

Thanks for any help and guidance that you can offer.

Adam


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Feb 2010, 10:49 AM
Hi,

The Filter Expression of the grid is usually reset on Rebind that is triggered by sorting,paging etc.You can store the expression e.g  ina  session and reset the expression on  rebind as shown in the link below:
Saving grid settings on a per user basis

Thanks,
Shinu
0
Mike Dennis
Top achievements
Rank 1
answered on 23 Feb 2010, 05:28 PM
Doesn't the example here do that without the extra code of having a class to save and load the grid preferences?  I'm not sure what setting it is though if it is..  Unless that is a newer build than the current released one.
0
Adam
Top achievements
Rank 1
answered on 25 Feb 2010, 02:16 PM
Mike:

Hopefully this can help you out... I struggled with your exact sentiment, but I am guessing that example fails to do a full rebind, despite doing a postback.  After being informed that the filter is not kept through a rebind I was able to "fix" this by storing the filter expression on PreRender and re-applying it at any point in lifecycle prior to the ItemCommand (as that may change the filter, etc.)  It did not require a full class (simply saving the string via ViewState), though I used the class referenced as a guide.

In the end it was fairly simple and quick, but I'm curious why an example showing this exact behavior / fix is not available.  The one you referenced almost implies that the filter stays in place and definitely had me puzzled and looking for a missed setting for a while.

Adam
0
Mike Dennis
Top achievements
Rank 1
answered on 25 Feb 2010, 06:34 PM
Adam,

It looks like it was working different from the example for me because I had been using Rebind() from a button to toggle the filter on and off.  I had been doing that on the client side before, which looks like it had been working fine.  I had to switch the filter to being hidden by default though because there are so many columns that it expands way too wide when the filter is on and there are formatting issues once it did that too..

Mike
Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike Dennis
Top achievements
Rank 1
Adam
Top achievements
Rank 1
Share this question
or