0

I have created a LWC datatable. I have a picklist field (LeadSource) set as "editable" true. But when trying to update the column it shows a text box and not the LeadSource options

enter image description here

is there a way to display the picklist options in the datatable as such:

enter image description here

lwc:

    import { LightningElement, api, wire } from 'lwc';
import getContacts from '@salesforce/apex/ContactControllerv2.getContacts';


const COLUMNS = [
    { label: 'FirstName', fieldName: 'FirstName' },
    { label: 'LastName', fieldName: 'LastName' },
    { label: 'Email', fieldName: 'Email', type: 'email' },
    {
        label: 'Lead Source', fieldName: 'Product', type: 'picklist', editable: true, typeAttributes: {
            // options: { fieldName: 'pickListOptions' },
            value: { fieldName: 'Product' }
        }
    }

];

export default class ContactListv2 extends LightningElement {

    @api recordId;
    data = [];
    columns = COLUMNS;

     @wire(getContacts, { recordId : '$recordId' })
     wireContacts({ data, error }) {
        if(data) {
            let currentData = [];
            data.forEach((row) => {
                let rowData = {};
                rowData.FirstName = row.FirstName;
                rowData.LastName = row.LastName;
                rowData.Email = row.Email;
                rowData.LeadSource = row.LeadSource;

            });
            this.data = currentData;
            this.error = undefined;

        } else if(error) {
            this.error = error;
            this.data = undefined;
        }
     }
     

}
2

1 Answer 1

3

For now, the feature Adding "picklist" as data type on lightning data table is not supported. This idea is logged at here but looks like Salesforce is not looking at it.

1
  • 1
    Please use Custom Data Types for Lightning data table Dec 8, 2022 at 11:28

You must log in to answer this question.

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