Zum Hauptinhalt gehen

Setting Drop Down List Selected Value

Kommentare

6 Kommentare

  • Kevin Rathgeber

    I just realised "current" doesn't even work properly as the form defaults to the 1 option no matter what current says. This is despite the source output showing it selected correctly. It is like the control is not refreshing properly.

    1
  • Nelson Dobbs

    Try the "Set Current Form Element Item" activity.

    0
  • Kevin Rathgeber

    /facepalm

    Thanks for the info. Find it interesting that unless you know all the available activities it is pretty easy to miss when you should be using an activity vs using the object directly. I hadn't expected it to be a separate activity.

     

    And of course looking back at the documentation it is listed right there at the bottom of "current" property

     

     

    0
  • Vogelzang, Nienke

    I ran into the same problem. However, the 'set current form element item' does not solve it for me. The form still defaults to the 1 option. While the source output is showing the selected correctly. I still feel like my control is not refreshing properly.

    0
  • Jack Charde

    The Set Current Form Element Item also only works on form elements that allow a single selection. Is there a method to set the active selection on a multi-select ListBox element? 

    I'm thinking something like providing an array of items (basically creating an ItemsRef data type) to the form elements value, for example: 

    = $form.state.elementID.value = [{"label": “option 1”, “value”: “option 1 value”}, {"label":"option 2", “value”: “option 2 value”}]

    I have not had success attempting this. When I try to set the ListBox element's .value.items property this array of items, I get a browser console error, as .value.items is undefined. 

    For me, it's undefined because I'm building an attribute updater form, which pulls current attributes from the user-supplied ID and populates the form, and before it tries populating the ListBox, there is no selected value, so of course .items is undefined (it's only defined if there has been a selection). I have all form elements populated, except the ListBox ones, because I can't get around this issue.

    0
  • Ken Lyon

    Jack Charde I think your idea of setting the value is correct. However, please use the Set Form Element Property activity. Any time you're dealing with a Form Element it's better to use the activities designed for this purpose as they ensure the form is refreshed properly.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.