1. #1
    Sencha User
    Join Date
    Feb 2009
    Posts
    38
    Vote Rating
    0
    soma13 is on a distinguished road

      0  

    Default SimpleComboBox -> sort

    SimpleComboBox -> sort


    Hi All,

    I want to sort items of SimpleComboBox<String> after I added a new item to it dynamically.

    Is there a good solution to sort item of a SimpleComboBox<String>?

    Example:
    SimpleComboBox<String> = ...
    ...
    String newItem = "a new item";
    simpleComboBox.add(newItem );
    simpleComboBox.setSimpleValue(maxDistance);
    // now, have to reorder items of it


    thx
    SoMa

  2. #2
    Sencha User
    Join Date
    Jun 2009
    Location
    Flanders
    Posts
    45
    Vote Rating
    0
    daddieke is on a distinguished road

      0  

    Default


    I don't use this but I suppose you can sort the Store of a SimpleComboBox too.

  3. #3
    Sencha User
    Join Date
    Feb 2009
    Posts
    38
    Vote Rating
    0
    soma13 is on a distinguished road

      0  

    Default


    Hi,

    Thank you for your answer. After it I have found the good solution:

    (1) I have made a base modell data and a store:
    public class Apple extends BaseModelData
    ListStore<Apple> appleStore = new ListStore<Apple>();

    (2) I made a good working equals method!
    Example: http://javarevisited.blogspot.com/2011/02/how-to-write-equals-method-in-java.html

    (3) I use ComboBox instead of SimpleComboBox

    (4) add a new item and sort my store:
    Apple newAppleModel = new Apple( "red", 13);
    if ( ! appleStore.contains(newAppleModel) ) // it uses the equals method!
    {
    appleStore.add(newAppleModel);
    }

    appleStore.sort("weight", SortDir.ASC);
    appleCombobox.setValue(newAppleModel);


    Thx
    SoMa

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    1
    Vote Rating
    0
    LaurentT is on a distinguished road

      0  

    Default I had the same problem but I finally found out

    I had the same problem but I finally found out


    Use
    Code:
    yourSimpleComboBox.getStore().sort("value", SortDir.ASC);
    This "value" string is the id field used by Ext GWT for SimpleComboBox

Thread Participants: 2