0

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.

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .