I know that it is possible to dynamically set menu items per each row of lightning-datatable, but I have a requirement to completely hide the action menu items for the particular rows which satisfy some condition.

Is this even possible to achieve using lightning-datatable?


To implement this, several changes have to be made.

The first one: class should be added to cellAttributes to get the value from cssClass column in the data


The second piece. The data should be updated to include standard classes 'slds-hide' to hide menu or 'slds-show' to show menu

dataRow.cssClass = this.isOrphaned(dataRow) ? 'slds-hide' : 'slds-show';

Finally, the third piece.

The table may look weird because of no lines between rows where actions are hidden, to mitigate this, a fake additional column is added after the missing one to display the lines under rows which lack the menu items

        fixedWidth: 1, hideDefaultActions: true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.