How to populate a selectBox dynamically?

Hi.
How can I populate a selectBox in the property panel?

I can do it statically like this:

 if (is(element, 'bpmn:Lane')) {
    group.entries.push(entryFactory.selectBox({
      id : 'myEntity',
      description : '',
      label : 'myEntity',
      selectOptions : [ { name: 'name1', value: 'value1' },
                                 { name: 'name2', value: 'value2' }],
      modelProperty : 'myEntity'
   }));

Now, I’d like to assign selectOptions dinamically, how can I do that?

Is there any documentation about the use of set and get functions when defining and entry?

Hi,

Every time you switch focus from other element to this one, group.entries.push(entryFactory.selectBox(...) would be called again.

So just generate values before that call and provide them as selectOptions.

Hope this helps.

Cheers,
Vladimir

Hi.
My data to populate de selectOptions are coming from and ajax request, this ajax request returns a json, then I parse this json to convert it in an object array [{name: ‘aname’, value: ‘avalue’. …]. having that result, how can I update the selectOptions async?

Hi @thormelk,

there is no proper way of updating the selectOptions in an async way. You could try to inject the options from your ajax call into the DOM after a request is received, but this would be more of a workaround.

I created an issue for that, because we should support that natively in the long term.

Please see this thread for more details.