Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How can I get selected value from SelectItem ?

    I have below code and getting error.
    And I'm using smartgwtee-2.1 version.
    Thanks for your help
    code:
    final SelectItem projectItems = new SelectItem();
    projectItems.setDisplayField("name");
    projectItems.setTitle("Project");
    projectItems.setWidth(250);
    projectItems.setOptionDataSource(projects);
    projectItems.addChangedHandler(new ChangedHandler() {
    public void onChanged(ChangedEvent event) {
    ListGridRecord selected = projectItems.getSelectedRecord();
    }
    });
    error:

    java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord
    at com.smartgwt.client.widgets.form.fields.SelectItem.getSelectedRecord(SelectItem.java)

    #2
    If you just want the value then use getValue()

    Comment


      #3
      [Solved] Thanks a lot

      Thank you for your super fast replay.
      The error came from my DataSource because it return record[].
      So I should change my Datasource return type from record[] to ListGridRecord[].
      Thanks again.

      Comment


        #4
        How about the last selected item value? For instance you have SelectItem multiple[true], getting the value would be easy but getting the last selected item is a bit blur.

        Comment

        Working...
        X