+ Start a Discussion
Ramesh DepaiahRamesh Depaiah 

Hide button inside Lightning Datatable based on row value

I need to hide the View button inside Lightning Datatable based on Team Group Name in that same row 
User-added image

If team Group name is blank then view button must be hidden and if team group name is not blank then i need to show view button
Here is my code:
columns: [ {label: "Course Title", fieldName: "CourseTitle", type: "text"}, {label: "Team Group Name", fieldName: "TeamGroupName", type: "text"}, {label: "Campus Name", fieldName: "CampusName", type: "text"}, {label: "Course", fieldName: "Course", type: "text"}, {label: "Section ID", fieldName: "SectionID", type: "text"}, {label: "Session", fieldName: "Session", type: "text"}, {label: "Course Level", fieldName: "CourseLevel", type: "text"}, {label: "Term Length", fieldName: "TermLength", type: "text"}, {type: "button", typeAttributes: { label: 'View', name: 'View', title: 'View', disabled: false, value: 'view', iconPosition: 'left' }} ]
Component:
<aura:component implements="force:appHostable" controller="Teams_Controller"> <aura:attribute type="Account[]" name="acctList"/> <aura:attribute name="mycolumns" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/> <lightning:datatable data="{! v.acctList }" columns="{! v.mycolumns }" keyField="id" hideCheckboxColumn="false" onrowaction="{!c.viewRecord}"/>
 
bhanu_prakashbhanu_prakash
Hi Ramesh,
Mark as best answer, If it resloves !!
Try to remove below code from JSON
/ *, {
    type: "button",
    typeAttributes: {
        label: 'View',
        name: 'View',
        title: 'View',
        disabled: false,
        value: 'view',
        iconPosition: 'left'
    }
*/

Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com

 
Ramesh DepaiahRamesh Depaiah
Hi @Bhanu,
I dont want to remove the button completely, i want to show the button when team group name is not blank.

Thanks
Ramesh  
Enrik HyskoEnrik Hysko
Hi Ramesh,

You can follow this link: http://www.infallibletechie.com/2018/07/how-to-disable-and-enable-button-in.html  for the solution.

Mark as resloved if it helps :) 
Thanks,
Enrik Hysko