Results 1 to 6 of 6

Thread: Combobox select value

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Location
    The Netherlands
    Posts
    196

    Default Combobox select value

    I've a nasty problem here. I tried several things, however with no good result.

    I have a combobox which has a store, which gets its data from a query to the database.

    At a certain point i add a new item in the database. After that, i reload the store so it has the new value with store.reload(); Because this is an asynchronous process, i use the load event of the store for my other code.

    In the load event, i want to set the new value to be the selected value. However, no matter how hard i try, i don't get this to work!

    I tried first the combobox.select() function, however this doesn't work. Then i tried the setValue function. This worked, HOWEVER, when i open the combobox list again bij clicking it the list starts at the top instead at the end or beginning of the new value.

    So is there an easy way to select the latest added item in the combobox (NOT the last item, the last ADDED item) and to let the combobox scroll to the selected item if it is opened?

    Thanks.

  2. #2

    Default

    I have the same problem i think

    Added a new item to the store of my combobox, and selected it with setValue(string). The value was selected, but when i opened the list of the combobox it wasn't scrolled to the selected item...

    Help!

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    You use a "load" listener on the ComboBox's Store to set the value of the ComboBox? Should work.

  4. #4
    Sencha User
    Join Date
    Jul 2009
    Location
    The Netherlands
    Posts
    196

    Default

    first i use the 'reload()' function to get the new list for the combobox' store. Then i use the 'setValue' function on the combobox in the load-event (listener) with a string.

    Like this:

    store:

    animal_id, animal_name

    1 -> 'Dog'
    2 -> 'Cat'
    3 -> 'Pig'

    Combobox valueField: 'animal_id';
    Combobox displayField: 'animal_name';

    Then i do:

    combobox.setValue('Pig'); in the load event (let's say pig is the latest added record).

    Although it set 'Pig' in the textbox of the combobox, after i open the combobox list the list isn't scrolled to the pig item.

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Quote Originally Posted by nicobarten View Post
    first i use the 'reload()' function to get the new list for the combobox' store. Then i use the 'setValue' function on the combobox in the load-event (listener) with a string.

    Like this:

    store:

    animal_id, animal_name

    1 -> 'Dog'
    2 -> 'Cat'
    3 -> 'Pig'

    Combobox valueField: 'animal_id';
    Combobox displayField: 'animal_name';

    Then i do:

    combobox.setValue('Pig'); in the load event (let's say pig is the latest added record).

    Although it set 'Pig' in the textbox of the combobox, after i open the combobox list the list isn't scrolled to the pig item.
    That's because you must set the value to 3!

  6. #6
    Sencha User
    Join Date
    Jul 2009
    Location
    The Netherlands
    Posts
    196

    Default

    Thank you, although i had some other problems which shut my eyes for this a bit, this was indeed the fix.

    Simple, but you have to know

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •