Using lightning-combobox i am able to display required picklist values but trying to achieve below two options.
Allowing users to unselect back to none from the selected value
As of now if user selects any picklist value there is no way to remove it , is there any quick way to achieve this? Below is the sample code i am running.
<template> <lightning-combobox name="progress" label="Status" value={value} placeholder="Select State" options={StatePicklistValues} onchange={handleChange} ></lightning-combobox> </template>
Javascript sample code:
import { LightningElement, track } from 'lwc';
import ADDRESS_OBJECT from "@salesforce/schema/Address_c";
import STATE_FIELD from "@salesforce/schema/Address_c.State__c";
export default class ComboboxBasic extends LightningElement {
@track value = 'inProgress';
@wire(getObjectInfo, {
objectApiName: ADDRESS_OBJECT
})
objectInfo;
@wire(getPicklistValues, {
recordTypeId: "$objectInfo.data.defaultRecordTypeId",
fieldApiName: STATE_FIELD
})
StatePicklistValues;
}
In above code sample on load the component display the place holder text "Select State" but once this is selected there is no way to unselect the value.
- Is there a way to change the order of picklist values to be displayed, as of now i am changing the order in object level. Instead of this is there a way i can follow a different order to display the picklist values than defined on object level.