Picklist
Reference
- The
Picklistcomponent is display dropdown component designed for single or multi-select functionality. - It uses a
Dropdowncomponent and maps options for display and selection.
Props
-
isMultiselect- Type:
boolean - Description: Enables multi-select functionality if
true.
- Type:
-
isDisabled- Type:
boolean - Description: Disables the dropdown if
true.
- Type:
-
fieldValue- Type:
Array | string - Description: The currently selected value(s).
- Type:
-
options- Type:
Array - Description: The list of options to display in the dropdown.
- Type:
-
onEdit- Type:
function - Description: Callback triggered when the selected value(s) change.
- Type:
-
onFocusOut- Type:
function - Description: Callback triggered when the dropdown loses focus.
- Type:
-
isLoading- Type:
boolean - Description: Displays a loading indicator if
true.
- Type:
-
customStyle- Type:
object - Description: Custom styles for the dropdown.
- Type:
-
placeholder- Type:
string - Description: Placeholder text for the dropdown.
- Type:
-
showClearValue- Type:
boolean - Description: Displays a clear button to reset the selection if
true.
- Type:
-
menuPlacement- Type:
string - Default:
'auto' - Description: Controls the placement of the dropdown menu (e.g.,
'top','bottom').
- Type:
-
isDeactiveOptions- Type:
boolean - Default:
true - Description: Determines whether disabled options should be included.
- Type:
Usage Example
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { Picklist } = protrakComponents;
const options = [
{ name: 'option1', displayName: 'Option 1', disabled: false },
{ name: 'option2', displayName: 'Option 2', disabled: true },
{ name: 'option3', displayName: 'Option 3', disabled: false },
];
return (
<Picklist
isMultiselect={true}
fieldValue={['option1']}
options={options}
onEdit={(newValues) => console.log('Selected:', newValues)}
placeholder="Select options"
showClearValue={true}
/>
);
};
- This renders a multi-select dropdown with options, a placeholder, and a clear button. It logs the selected values on change.