1. #1
    Sencha User
    Join Date
    Oct 2010
    Location
    Kuşadası/Aydın/Turkey
    Posts
    94
    Vote Rating
    0
    TrojanMyth is on a distinguished road

      0  

    Default Unanswered: How can I make editable combo box ?

    Unanswered: How can I make editable combo box ?


    I want to make combo box either can edit writing or select from the list. I made a test with the codes below but when I enter the writing and blur from combobox,writing is deleting. What can I make for this problem ?
    PHP Code:
    database = new ComboBox<DatabaseEntityProxy>(datasetDatabaseModule.Properties.label());        database.setEditable(true);        database.setAutoValidate(false);        database.setLoader(dataset.getLoader());        database.setForceSelection(false);        database.setAllowBlank(false); 

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    (easier to read code)
    Code:
    database = new ComboBox<DatabaseEntityProxy>(dataset, DatabaseModule.Properties.label());
    database.setEditable(true);
    database.setAutoValidate(false);
    database.setLoader(dataset.getLoader());
    database.setForceSelection(false);
    database.setAllowBlank(false);
    The trick is that you need to convert the String the user is entering into a DatabaseEntityProxy so that getValue() can return a real value. Standard ways for doing this include providing a custom PropertyEditor via setPropertyEditor (default is com.sencha.gxt.cell.core.client.form.ComboBoxCell.ComboPropertyEditor<T>).

    A second option would be to override the ComboBoxCell.selectByValue(String) method so that whenever a string is checked, it can return a real object of some kind.

    In either case, it is up to your code to decide how to turn that string into an object, and whether to do other work like adding it to the list store.

Thread Participants: 1