• #32783
     Prachi #6
    Forcetalks

    How to give input field in lightning:datatable?

    How to give input field in lightning:datatable?

    #33133
    Forcetalks

    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¬† .

    Summary:

    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.

CONTACT US

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

Sending

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

or    

Forgot your details?