How do I get lightning:datatable to do some undocumented thing X?

Canonical Question

I want to do <some really cool thing> with a lightning:datatable, but I can’t seem to figure out how to do it. I checked the documentation, but I did not see a way to implement <this really cool feature I need>.

Perhaps I want to provide tooltips, or a pick list, or alter the behavior of the menus, or display images, or show a custom component I created, or define a new row-level click behavior, or alter the keyboard event handlers, etc.

Can I somehow do this?


Canonical Answer

Please note: if you have been directed to this question and answer, what you are attempting to do with lightning:datatable cannot be done. You will need to find an alternative method, such as using a normal SLDS data table instead.

Unfortunately, in the general sense, the features in the documentation are all that you get. It is possible capture bubbled events from the lightning:datatable itself and modify its look with custom styles. However, because of Locker Service security restrictions, you generally cannot modify the component’s behavior, DOM, or internal CSS styles. If you do not see a feature mentioned in the official documentation, what you are attempting to do is most likely not possible.

The standard workaround for right now is to write your own SLDS-compatible data tables. Please remember to check the release notes with each new release to see if a feature you were looking forward to has been released, and also remember to search for and vote on/post an Idea for this feature that you would like to see in a future release.

Source : Link , Question Author : Community , Answer Author :
3 revs

Leave a Comment