Topic: Unable to apply background color to rows in a datatable

pwlewis premium asked 2 years ago


Expected behavior*I have applied tr classes such as table-warning to table rows within a datatable div, and I thought the row colour would change?*Actual behavior*All rows have the same colour regardless of the tr class. Is it not possible to have different table row background colours in a datatable?*Resources (screenshots, code snippets etc.)<div class="datatable"> <table class="table" id="processed_files" > <thead><tr><th>Type</th><th>Name</th><th>Status</th><th>Sent RT</th><th>Sent Regs</th><th>Notes</th><th>Created</th></tr></thead> <tbody> <tr class="table-success"> <td>ITWBV_SUB </td><td>TR_724500D4BFEWKWVC1G62_09_20220117_3001.xml</td><td>SENT_TO_RT</td><td>3</td><td>0</td><td>Sent file</td><td>15:51:03</td></tr>
<tr class="table-warning"> <td>TTWEO_SUB </td><td>TR_724500D4BFEWKWVC1G62_01_20220308_2001.zip</td><td>SENT_FOR_SFTP</td><td>0</td><td>101</td><td>Submission file processed, ready for SFTP</td><td>15:13:41</td> </tbody> </table> </div>


Dawid Wajszczuk staff answered 2 years ago


Hi,

You need to use format option for this. Here is the snippet https://mdbootstrap.com/snippets/standard/d-wajszczuk/3753541#js-tab-view. And here is the link to the example form our documentation https://mdbootstrap.com/docs/standard/data/datatables/#section-cell-format. Under API tab you can find all the available options.

Keep coding,
Dawid



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

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No