Topic: Retain custom properties when instantiating datatable
Dylan DeMarco pro premium priority asked a year ago
Expected behavior If I am creating a datatable using a div with the class datatable around HTML, I would expect that custom data- attributes defined in the cells to be present in the final rendering. For example:
<!-- In my HTML file-->
<td data-my-custom-prop="42" ><small>Cell content</small></td>
...
<!-- when inspecting the element on the rendered page -->
<td [...styles from formatCell] data-mdb-field="field_3" false="" data-my-custom-prop="42">
<small>Cell content</small>
</td>
Actual behavior
<!-- In my HTML file-->
<td data-my-custom-prop="42" ><small>Cell content</small></td>
...
<!-- when inspecting the element on the rendered page -->
<td [...styles from formatCell] data-mdb-field="field_3" false="">
<small>Cell content</small>
</td>
I.e. the custom prop is not carried into the rendered datatable
Resources (screenshots, code snippets etc.)
Grzegorz Bujański staff answered a year ago
We are currently working on more extensive tables. We do not plan to add such a feature in Datatables, but our new product will allow you to set custom classes, styles, and data attributes
Dylan DeMarco pro premium priority commented a year ago
Good to know! Thank you. In the meantime, I found a workaround for anyone else with a similar goal: if you put the cell content inside a within the table cell and give the div the custom property, it will be retained!
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: -
- Device:
- Browser:
- OS:
- Provided sample code: No
- Provided link: No