function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sachin Bhalerao 17Sachin Bhalerao 17 

picklist in inline editing of lightning datatable

Dear Team ,

Greetings !!!

I am trying to integrate picklist in inline functionality of lightning datatable . Type column is picklist in below code . My controller code are as follows :

({
    doInit : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'Name', type: 'text', editable: true, initialWidth: 750},
            {label: 'Phone', fieldName: 'Phone', type: 'phone', editable: true},
            {label: 'Rating', fieldName: 'Rating', type: 'text', editable: true},
            {label: 'Number Of Employees', fieldName: 'NumberOfEmployees', type: 'number', editable: true},
             {label: 'Type', fieldName: 'Type', type: 'List', editable: true}
        ]);
        
        var action = component.get("c.details");
        action.setCallback(this, function(response) {
            var state = response.getState();
            
            if (state === "SUCCESS") {
                var res = response.getReturnValue();
                component.set("v.mydata", res);
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } 
                else {
                    console.log(response.getReturnValue());
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    saveTable : function(component, event, helper){     
        //var data = component.get("v.mydata");
        var draftValues = event.getParam('draftValues');
        var action = component.get("c.updateDetails");
        action.setParams({lstForm  : draftValues});
        action.setCallback(this, function(response) {
            var state = response.getState();
            
            if (state === "SUCCESS") {
                var res = response.getReturnValue();
                $A.get('e.force:refreshView').fire();
                alert('Updated Successfully...');
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log(response.getReturnValue());
                }
            }
        });
        $A.enqueueAction(action);
    }
})

Kindly suggest some solution in order i am able to perform this functionality .

Thanks & Regards
Sachin Bhalerao
Best Answer chosen by Sachin Bhalerao 17
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sachin,

Greetings to you!

In lightning:datatable picklist will not list down dropdown values in Inline Edit mode. There's an idea which is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.

https://success.salesforce.com/ideaView?id=0873A000000PZJ4QAO

As a workaround, change the type of the picklist column from picklist to button. On button click, open a modal which fetches and displays the picklist values. Or you can use a custom SLDS data table.

Please refer to the below link which might help you further with the above requirement.

http://www.sfdcpanda.com/lightning-datatable-with-picklist-select-powered-in-edit-mode/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Sachin,

Greetings to you!

In lightning:datatable picklist will not list down dropdown values in Inline Edit mode. There's an idea which is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.

https://success.salesforce.com/ideaView?id=0873A000000PZJ4QAO

As a workaround, change the type of the picklist column from picklist to button. On button click, open a modal which fetches and displays the picklist values. Or you can use a custom SLDS data table.

Please refer to the below link which might help you further with the above requirement.

http://www.sfdcpanda.com/lightning-datatable-with-picklist-select-powered-in-edit-mode/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
Venky KambhamVenky Kambham
We can achieve this by creating our own datatable. Check this blog post for full solution for how to use picklist field in lightning datatable.

https://vkambham.blogspot.com/2020/01/picklist-supported-lightning-editable-datatable.html
lkatneylkatney
Below are the links to support picklists in Lightning Datatable in LWC as well.
https://blog.lkatney.com/2019/11/13/picklist-in-lightning-datatable/
https://www.playg.app/play/picklist-in-lightning-datatable
lkatneylkatney
I have moved code from Venky's blog to https://www.playg.app/play/picklist-in-lightning-datatable-aura so that it can be imported directly into any salesforce org for future purposes for myself. This will also make it reusable for other users.

@Venky, I hope this is fine with you.
Jaykumar RathodJaykumar Rathod
You can also create a custom cell template to support new data type. Check out 
Creating Custom Data Types section on page https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation.
Yogendra JangidYogendra Jangid
Currently we don't have any such OOB solution but can be achieved by using LWC and extending the lightning datatable to create our own custom type picklist. 
To know more how to do this pleaes visit following
https://inevitableyogendra.blogspot.com/2021/04/picklist-in-lightning-datatable.html
I have also created a package
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0K000000wUik
you can install this make it work.