Announcement

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

    SelectItem default value

    I have a SelectItem that displays a list of columns from a ListGrid. The valueField is the name of the column, while the displayField is the title of the column. So, for instance:

    value: "OPERATOR"
    display value: "Operator Name"

    Now, suppose I set the defaultValue to "Operator Name". Then, the SelectItem will display the value I want, but when I getValue() on the SelectItem I get "Operator Name" when I want "OPERATOR". Or, I can set the defaultValue to "OPERATOR", which returns the correct form value, but then the SelectItem displays "OPERATOR" when I want to display "Operator Name". What approach would Isomorphic recommend to remedy this problem?

    I thought of using setValue() to choose a value from the item's pick list (thereby getting the correct value and display value), but the pick list apparently doesn't load until I first click on the dropdown to display the select list. It seems to me I could solve this problem by forcing the pick list to load when the DynamicForm loads, and then selecting the correct record from it. But how do I do that?

    #2
    Aha! I seem to have posted too quickly. The solution is to overload the form's initWidget() method, run a function to create the valueMap for the SelectItem, and then call setValueMap(valueMap) before calling setValue(value). Then everything works properly.

    Comment

    Working...
    X