You need to sign in to do that
Don't have an account?
Ramesh D
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
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}"/>
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}"/>
Mark as best answer, If it resloves !!
Try to remove below code from JSON
Mark as resloved if it helps :) :)
Thanks,
Bhanu Prakash
visit ForceLearn.com
I dont want to remove the button completely, i want to show the button when team group name is not blank.
Thanks
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