• #32783
     Prachi #6

    How to give input field in lightning:datatable?

    How to give input field in lightning:datatable?


    Hi Prachi,

    To give an input field to a lightning datatable,

    • First make an attribute of the type list(say name-mycolumns).
    • Then, in an init function in a javascript controller, set this component with the field label , field type and any other thing if you want.Those are the things which are assigned to that ‘mycolumn’ atttrbute.
    • Lastly, get this attribute in column property of lightning:datatable¬† .


    Step 1:

    <aura:attribute name=”mycolumns” type=”List”/>

    Step 2:

    init: function (cmp, event, helper) {
    cmp.set(‘v.mycolumns’, [
    {label: ‘Contact Name’, fieldName: ‘Name’, type: ‘text’},
    {label: ‘Phone’, fieldName: ‘Phone’, type: ‘phone’},

    Step 3:

    <lightning:datatable¬†columns=”{! v.mycolumns }” />

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?