Hybrid View

  1. #1
    Ext GWT Premium Member
    Join Date
    Nov 2011
    Posts
    2
    Vote Rating
    0
    ibetts03 is on a distinguished road

      0  

    Default Unanswered: Combobox hidden value question

    Unanswered: Combobox hidden value question


    I have the following combobox:
    states.add(StaticData.getStates());
    cState = new ComboBox<State>();
    cState.setEmptyText("Select a state...");
    cState.setDisplayField("statename");
    cState.setValueField("abbr");
    cState.setWidth(150);
    cState.setFieldLabel("State");
    cState.addSelectionChangedListener(new SelectionChangedListener<State> ()
    {
    @Override
    public void selectionChanged(SelectionChangedEvent<State> se)
    {


    Window.alert("State = " + cState.getRawValue());



    }
    });
    cState.setEditable(false);
    cState.setVisible(false);
    cState.hide();
    cState.setStore(states);
    cState.setTypeAhead(true);
    cState.setTriggerAction(TriggerAction.ALL);
    right.add(cState);
    My model is:
    public State(String abbr, String statename) {
    set("abbr", abbr);
    set("statename", statename);
    }

    I can load the store, display the data - however the selected value is not the one in the valuefield - it is the one in the displayfield. I need to be able to access the valuefield (abbreviation) to store it in the database...and I need to keep the displayfield as the text name as well. Does gxt handle name-value pairs? I have tried several variations and none has worked yet.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Nov 2010
    Posts
    209
    Answers
    4
    Vote Rating
    -2
    Ersmarker has a little shameless behaviour in the past

      0  

    Default


    You can use
    se.getSelectedItem(); from the selection event
    or cState.getSelection()

Thread Participants: 1

Tags for this Thread