Announcement

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

    How to format JSON for DataSourceEnumField

    I have a RestDataSource that gets dynamically created, that is later bound to a DynamicForm in my app. Evrything is working fine, except I cannot get the drop-down to work properly for my enum-fields.

    I have the following field declaration:

    Code:
    DataSourceField field = new DataSourceField(id, FieldType.ENUM, name);
    field.setValueXPath("foo/bar");
    field.setChildTagName("value");
    field.setMultiple(true);
    And the JSON response looks like this:

    Code:
    {"response":
      {"status":"0",
       "startRow":"0",
       "endRow":"1",
       "totalRows":"1",
       "data":[
           {"foo":[
              {"bar":[
                  {"value":"0"},
                  {"value":"1"},
                  {"value":"2"},
                  {"value":"3"},
                  {"value":"4"},
                  {"value":"5"},
                  {"value":"6"},
                  {"value":"7"},
                  {"value":"8"},
                  {"value":"9"}]}]}]}}
    However, this does not create a drop-down of values, the drop-list remains empty, while the first element of the drop down is set to [object Object], [object Object], [object Object] (and so on).

    How should I format my json to get the drop down properly populated?

    I'm using SmartGwt from 24/11 2010, on a Windows 7 machine, running my app in the latest Chrome, Firefox and IE.

    #2
    You don't provide lists of valid values in the dsResponse. You specify them via either setValueMap() or using an optionDataSource to refer to a second DataSource that dynamically returns legal values. See the docs for these properties for further details.

    Comment

    Working...
    X