Select to view content in your preferred language

How to set a default selection on the Jimu Multiselect control?

402
0
08-24-2023 04:00 AM
DominicRorke1
New Contributor

I've developing a custom widget for Experience Builder, and I'm having issues implementing the Jimu Multiselect control, documented here: https://developers.arcgis.com/experience-builder/storybook/?path=/docs/components-jimu-ui-index-mult...

I can populate the multiselect with items, and I am capturing the item click event.  What I can't work out, is how to set a default selection.  When the multiselect is first opened, it looks like this:

DominicRorke1_0-1692874112081.png

And I want to be able to check some of these items by default, such as this:

DominicRorke1_1-1692874179620.png

I've tried implementing the 'defaultValues' property, but with no more than the very limited documentation provided by ESRI, and a storybook component that crashes when I click 'Set object' for this property, I have not been able to get this working:

DominicRorke1_2-1692874372434.png

 

Here's my code for reference (without any attempt to set default selection):

 

<MultiSelect
      onClickItem={(e, value, allSelections) => itemClicked(e, value, allSelections)}
      displayByValues={function noRefCheck () {}}  
      buttonProps={{
        size: 'sm',
        icon: true,
        title: 'Toggle columns',
        className: 'btn_columnToggle'
      }}
      items={[
        {
          label: 'Item 1',
          value: 'item-1'
        },
        {
          label: 'Item 2',
          value: 'item-2'
        },
        {
          label: 'Item 3',
          value: 'item-3'
        },
        {
          label: 'Item 4',
          value: 'item-4'
        }
      ]}      
    />
    </div>

 

Appreciate if you can help me with this, as I'd quite like to use this Jimu component.

ESRI - Please improve your documentation for the Jimu component library, and for Widget development generally.

0 Kudos
0 Replies