Datatable - Row - Color


Topic: Datatable - Row - Color

Sense4 pro premium priority asked 2 years ago

Hello

I use MDB 5 Standard and create datatables using data attributes.

When I add a class ord a style to a table row or a table cell it will be replaced by the datatable once rendered and I can't figure out how to pass classes or styles to individual cells or rows using datatable.

If I remove the datatable making the table a "normal" table the colors in each cell are working fine.

Example:

<div class="datatable" id="datatable" data-mdb-entries="100" data-mdb-sm="true"> <table class="table table-responsive-sm align-middle mb-0 bg-white"> <thead> <tr> <th>A column header</th> </tr> </thead> <tbody> <tr class="red-background"><td>This ROW WONT HAVE A RED BACKGROUND CLASS</td></tr> <tr><td class="green-alien">This CELL WONT HAVE A GREEN-ALIEN CLASS</td></tr> </tbody> </table></div>

How do I pass css classes to rows or cells when using datatables?

Is it possible to do while using data attributes or do I need to make it in javascript and add the color or class to the table row array?

Best regards

Michael


kpienkowska staff answered 2 years ago

Datatable strip regular CSS styles from the table. To add formatting you need to apply the color option to a cell. There is an example in the documentation of custom formation: https://mdbootstrap.com/docs/standard/data/datatables/#section-cell-format


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 6.0.1
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No