Examples › Custom row or cell attributes
Adding custom attributes to table rows or cells can be useful for testing purposes, for analytics, or for handling events the DataTable doesn’t expose a dedicated property for.
To add custom attributes to table rows, use the customRowAttributes property. It accepts a function that receives the current record and its index as arguments and returns an object whose properties are applied as attributes to the corresponding row.
Similarly, each column accepts a customCellAttributes property, which works the same way, but applies the returned attributes to the column’s cells.
Inspect the table below to see the attributes generated for each row and cell:
Here is the code:
Handling middle-clicks
Since the returned object can also contain event handlers, here is how you could use the customRowAttributes property to handle middle-clicks on table rows:
Here is the code:
Head over to the next example to discover more features.












