https://developer.salesforce.com/docs/component-library/tools/playground/jhnQTPhHF/4/edit
Is it possible to create cascaded dropdown in sf lightning. Please have a look at above playground link.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityhttps://developer.salesforce.com/docs/component-library/tools/playground/jhnQTPhHF/4/edit
Is it possible to create cascaded dropdown in sf lightning. Please have a look at above playground link.
Yes, you should be able to do something like this:
@track value = '';
@track subStatusOptions = [];
substats = [{
status: "Status1",
subs: [{
label: "substatA",
value: "substatA"
},{
label: "substatB",
value: "substatB"
}]
},{
status: "Status2",
subs: [{
label: "substatC",
value: "substatC"
},{
label: "substatD",
value: "substatD"
}]
},{
status: "Status3",
subs: [{
label: "substatE",
value: "substatE"
},{
label: "substatF",
value: "substatF"
}]
}];
get statusOptions() {
return [
{ label: 'Status1', value: 'Status1' },
{ label: 'Status2', value: 'Status2' },
{ label: 'Status3', value: 'Status3' },
];
}
handleChange(event) {
// capture the selected value of first combo and use to filter the second
this.value = event.detail.value;
this.subStatusOptions = this.substats.find(ss=>ss.status==event.detail.value).subs
}
Also, you might want to rename the onchange
event in the second lightning-combobox
or it will error.