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 Lightning data table?

Dear Team ,

Greetings !!!

Please let me know can we use Picklist in Lightning data table in lightning component.

Thanks & Regards
Sachin Bhalerao
Ahmed Ansari 13Ahmed Ansari 13

Hi Sachin Bhalerao 17,

Please go through link  https://success.salesforce.com/answers?id=9063A000000pg0xQAA.

Regards,

Ahmed Ansari

 

Ajay K DubediAjay K Dubedi
Hi Sachin,

Aura lightnig data table is not supported with picklist, but this possible from LWC with the help of custom types and here is the sample code for your reference - https://www.playg.app/play/picklist-in-lightning-datatable

are if you still using/require with Aura, then the alternative ways that do use an HTML table instead of DataTable (or) user needs to enter the correct picklist options.

Supported attributes:
action
boolean
button
button-icon
currency
date
date-local
email
location
number
percent
phone
text
url

Refer below the link-

https://developer.salesforce.com/forums/?id=9062I000000g92jQAA

https://developer.salesforce.com/docs/component-library/bundle/lightning:datatable/documentation

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



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com  (http://www.ajaydubedi.com )
 
Deepali KulshresthaDeepali Kulshrestha
Hi Sachin,

You can design a hardcoded picklist like this and set the value of that picklist as you like:

<aura:component>
    <lightning:select name="select1" label="How many tickets?" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
    </lightning:select>
</aura:component>

Or you can use a dynamic picklist value. 
Suppose you have a list of accounts and you want to put all the records in the options and want to get the Id of the record on selecting an option. You can do that like this:

<aura:component>
    <lightning:select name="select1" label="How many tickets?" required="true">
        <option value="">choose one...</option>
        <aura:iteration items="{!v.accList}" var="ac">
        <option value="{!ac.Id}">{!ac.Name}</option>
        </aura:iteration>
    </lightning:select>
</aura:component>


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com