FilterExpression cleared on sort

5 posts, 0 answers
  1. Adam
    Adam avatar
    13 posts
    Member since:
    Jul 2008

    Posted 18 Feb 2010 Link to this post

    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


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Feb 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 23 Feb 2010 Link to this post

    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.
  5. Adam
    Adam avatar
    13 posts
    Member since:
    Jul 2008

    Posted 25 Feb 2010 Link to this post

    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
  6. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 25 Feb 2010 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017