Examples › Pinning the last column
fix, fixed, affix, sticky
You may have noticed that when you are using row selection and the table needs to scroll horizontally, the checkbox column is always visible. This is because the checkbox column is pinned to the left side of the table.
In the same way, pinning the last column to the right side of the table could be useful when you have a table with many columns and you want to make sure the last column is always visible, even when the table is scrolled horizontally. For instance, you could use this feature to ensure that the row actions are always visible.
You can achieve this by setting the pinLastColumn
DataTable prop to true
:
Here is the code:
Using with column grouping
Here is an example of how you can pin the last column when using column grouping. Notice how the last group contains only one column, and how we are using an absolutely positioned custom title component to create the illusion that the Actions text is centered vertically:
Here is the code:
Head over to the next example to discover how you can pin the first column to the left side of the table.