TransWikia.com

Lightning Datatable - Dynamically Hide actions for specific rows on the basis of data

Salesforce Asked by Gaurav Sharma on December 7, 2021

I have a lightning data table with some columns and row-actions. These row actions are configured dynamically on the basis of row data. For example, If I am fetching some Payments data into my table and if the status(column) of a particular record(row) has value ‘Paid’, then the Row Actions should have ‘Refund’, ‘View Receipt’, ‘Send Receipt’ options available

enter image description here

otherwise if the status is ‘Failed’ the Row Actions dropdown should not be visible at all :

enter image description here

In my case, I am able to set the criteria for Row Actions but not able to hide the dropdown icon when there are no Row Actions. It has to be done dynamically from JS but I am not able to achieve it.

Code :
paymentsTable.html :

enter image description here

=========================================================

paymentsTable.js:

enter image description here
enter image description here
enter image description here

One Answer

You are putting cellAttribute inside typeAttribute both should be separate like this

 typeAttributes: { rowActions: actions},cellAttributes:{class:{fieldName:'cssClass'} }

you can also directly use "slds-hide" class instead of using static resource simply use

cssClass:'slds-hide'

Instead of "hideActionButton"

Answered by User6670 on December 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP