PostBack after my client side filter is resetting my filter selection

6 posts, 0 answers
  1. Tim
    Tim avatar
    57 posts
    Member since:
    Apr 2011

    Posted 08 Jun 2011 Link to this post

    Hi

    I have a ComboBox filter in a grid that has an 'All' state, which is the default.

    I have written some client side code to invoke a filter operation on my grid, and it filters
    just fine if I select.

    However after the postback occurs my Combo has the 'All' item selected.

    So I can never trigger a client side event to revert my grid to unfiltered.

    Helpppppppp
  2. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 08 Jun 2011 Link to this post

    Hi Tim,

    There are a few ideas I have that may help. For starters, is it possible for you to use the built-in filtering for RadGrid? That will greatly simplify the problem and ensure that your application remains manageable as it grows.

    If you need to use a RadComboBox for filtering, I would change the logic of selecting the "All" item. By default, the RadComboBox should persist its last selection after postback unless you override that logic. You could store the last selection and reselect it when the OnClientLoad event fires, but that's an infinite loop waiting to happen since that would also fire the OnClientSelectedIndexChanged event.

    If "All" is the first item in the RadComboBox (Item 0) it should be selected by default the first time, and then the previous selection should persist through postbacks.

    Let me know if that works for you,
    -Gimmik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tim
    Tim avatar
    57 posts
    Member since:
    Apr 2011

    Posted 08 Jun 2011 Link to this post

    Hmmm I wonder if you aren't quite understanding the problem I am seeing.

    I'm certainly not understanding the response. :-)

    Let me try to explain further.

    I have a Rad Grid that contains a column that just presents images. The only Filter control
    that seems to present correctly is the ComboBox.

    I have populated everything successfully. The first item in the Combo is representing my 'All" state,
    and you are correct, it is selected by default.

    When I select a different filter item in the combo I have a client side selection change event fire.
    I can see it fires because I put and alert in the script block.

    Briefly the text in the combo changes to the correct value and I trigger a tableview.filter on the grid.

    This filters the rows I see in the grid to what I want to see.

    However after the postback that occurs the combobox appears to be back in my 'All' state.
    So clicking on that item DOESN'T trigger my client-side event handler. So I cann't issue a tableview.filter 
    call with the NoFilter parameter as I had hoped.

    TIA    
  5. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 09 Jun 2011 Link to this post

    Hi Tim,

    I'm not sure why the RadComboBox is responding like that. You're best bet for an answer would be to submit your project to Telerik support. They'll be able to tell you why the control is behaving like that.

    But, let's think outside the box for a moment and see if we can't find an acceptable workaround. What about adding another default item to the RadComboBox server-side when the page loads the first time. Set the text of the item to "-- Select a Filter --" That way you will be able to select "All" (perhaps rename that to "No Filter") and the OnClientSelectedIndexChanged will fire. It's not ideal but it should work.

    Let me know what you think, I have a few other more complicated workarounds that you could try as well.

    -Gimmik
  6. Tim
    Tim avatar
    57 posts
    Member since:
    Apr 2011

    Posted 09 Jun 2011 Link to this post

    Hi Gimmik

    Somebody here suggested I have an empty item as my default and add an 'All' item as an additional item.

    That would at least allow me to return the grid to an unfiltered state.

    But that doesn't address the real problem that the combo used in the filter template doesn't
    indicate my current filter state. So the UI is inconsistent.  

    I did just find an article on your site the actually was to do with interelated combboxes, that were not being
    used as a filter.

    The thread was titled, 'related combobox values on postback'.

    It talks about setting the AllowCustomText property of the Combobox, disabling input,
    and finally doing on demand loading and highlighting of the appropriate item on the combobox dropdown opening event.

    While I wonder if this would solve my problem I am curious as to why it would take that much effort.

    I saw comments that Enabling View state and ViewStateMode should have solved my problem, it didn't.

    In the end I have implemented Custom filtering, as show in one of your examples.

    This gives me the behavior I need but this whole problem seems to have a much more complicated
    solution that I would have expected. I am a novice at this so there is a lot I don't know.

    Sorry for the long response, but I'm still hoping someone will point out the simple solution I missed.

    TIA
  7. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 09 Jun 2011 Link to this post

    Hi Tim,

    I'm glad you found a solution that worked for you. Normal behavior for the RadComboBox is to preserve the state through postback. I'm not sure why that behavior was being broken in your application. The other method I was going to suggest was manually saving and preserving the selection. You would also have to cancel the OnClientSelectedIndexChanged event that would get fired after the load, but it's alother option. If you get an answer as to why the state of the RadComboBox was being lost, please let me know.

    -Gimmik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017