ComboBox retains value but not text on return to page

4 posts, 0 answers
  1. Ken Lewis
    Ken Lewis avatar
    28 posts
    Member since:
    Sep 2009

    Posted 09 Feb 2013 Link to this post

    I created a couple of ComboBoxes and notice a strange thing if I do the following:

    1. Select an item.
    2. Navigate away from the page.
    3. Use the browser's Back button to return to the page.

    Upon returning, the ComboBox is blank (or the placeholder appears if I configured that). However, when I open the ComboBox, the item I had originally selected is highlighted. Thus, it appears that the value was retained though the text was not.

    Is there any way to make sure the text retains its value on returning to the page?

    (Note: I tried the same thing with a normal HTML select drop-down list, and the selected item remains selected upon return as expected.)

    Thanks,

    Ken
  2. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 28 Feb 2013 Link to this post

    I'm having the same problem.  I have a search form that posts to a view containing a grid with the search results.  If I click the back button to edit my search criteria, the dropdownlist always displays the first item in the list.

    Does anyone have a suggestion?

    Thanks,
    David A.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ken Lewis
    Ken Lewis avatar
    28 posts
    Member since:
    Sep 2009

    Posted 01 Mar 2013 Link to this post

    David,

    Here's the response I received from support:

    -----
    The value is not preserved because of the autocomplete attribute used on the text input. In order to preserve the text, you could change the attribute value through code after the combobox initialization:

    $(function () {
        var combo = $("#comboID").data("kendoComboBox");
        combo.input.prop("autocomplete", "on");
    });

    but please note that this would also enable the browsers default auto-completion which may cause two popups to be shown when typing - one from the browser and one from the combobox.
    -----

    I tried that and I indeed saw the two popups, which is not desirable. However, the behavior is not all that reliable. Sometimes my combos retain their values just fine and sometimes not. It's unfortunate that the combo behavior is so non-standard.

    I hope this helps get you closer to a workable solution.

    Ken
  5. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 01 Mar 2013 Link to this post

    Ken, many thanks for taking the time to post a reply.  I will try the solution you posted, but a decent solution I ended up with was using the standard DropDownListFor and adding a style of "k-textbox" to it.  Added a little padding and the arrow from the sprite.png as the background image for Chrome, as it was not displaying the pulldown button.

    David A.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready