General Category > ParamQuery Pro Evaluation Support

How to Add a Dropdown in Toolbar that Returns ID and Type on Selection

(1/1)

cui:
Hi everyone,

I want to add a dropdown menu in the toolbar where each option is represented by an object containing id, type, and title. Upon selection, I need to get both the id and type associated with that option. However, my current configuration does not work as expected.

Current Configuration
Here's how I've configured the dropdown:

--- Code: ---{
  type: 'select',
  options: [
    {
      id: -1,
      type: 1,
      title: '默认视图', // This should be displayed in the dropdown
    },
  ],
  value: -1,
  listener: function () {
    console.error('select');
  },
}
--- End code ---
However, this setup results in an error or does not correctly display the title nor returns the id and type upon selection.

Could anyone please guide me on how to achieve this? Specifically, how can I ensure that the dropdown displays the title and allows me to retrieve both id and type upon selection?
Any advice or pointers would be greatly appreciated.

Thank you in advance for your help!
Best regards

paramvir:
you may need to add labelIndx and valueIndx properties in the toolbar dropdown item.

Format of options is documented in column.editor section which also applies to dropdown in toolbar.

https://paramquery.com/pro/api#option-column-editor

cui:
      {
        type: 'select',
        options: listViewMode.value,
        valueIndx: 'id',
        labelIndx: 'title',
        listener(val) {
          console.error('sselect', val)
        },
      }
The method you provided is effective. Thank you for your help!

Navigation

[0] Message Index

Go to full version