MultiSelect - multiple default options

Already seen: Setting a default value for Multi Select Field in Data Manipulation Plugin while using an Initial Request

Hi! How can I set multiple default values for a multi select? Here is a simplified example below:


    .addMultiSelect<number, SelectFieldConfigSettings<number>>({
      path: 'steps',
      name: 'Steps',
      defaultValue: [1, 2, 3], // ERROR HERE
      settings: {
        allowCustomValue: true,
        isClearable: true,
        options: [{ label: '1', value: 1 }, { label: '2', value: 2 }, { label: '3', value: 3 }],
      },
    })

The code breaks at the defaultValue - because it wants a number only and not number[]. I can set the default value to 1 for example which works but only sets that one option as its default.

As a side point, I’d also like to leave options: [] blank because for this input selector, I want the user to be able to input their own arbitrary amount and values of numeric options. Is this possible?

Thanks,

Nicolas

@ventura once you start dealing with more complex situations like this what you want is to use a custom panel editor. You can read more about it here Add a custom panel option editor | Grafana Plugin Tools

Got it, thanks for the tip. It’s interesting to me though that the multi select’s default value accepts a type but the return value can be an array of type[] if multiple values are selected. The custom editor is probably the way to go for this, anyway.