top of page
Search
Writer's pictureLakshmi Deepak Inkurthi

How to Disable and Enable button in lightning:datatable based on Row Value

Updated: Sep 3, 2021

lightning:databale is salesforce base component to display collection of records in a well formatted way


There are times we may need to perform some dynamic actions around the row actions based on row values. Well this can be achieved by adding disabled attribute to your row actions


Lets take a look

{type: "button", typeAttributes: {
                label: 'View',
                name: 'View',
                title: 'View',
                disabled: { fieldName: 'disableButton'},
                value: 'view',
                iconPosition: 'left'
            }}

{fieldName : "disableButton"} assign the disableButton field to your recordset with true or false


When lightning datatable renders it checks the field value at row level , if the disableButton is true / false based on that it will enable or disable the row actions.


You add new attribute to your return value by doing foreach on the returnValues();







3,726 views0 comments

Comments


bottom of page