Change row class based on column value datatables


Topic: Change row class based on column value datatables

jmztaylor pro premium asked 2 years ago

Just as title says. Is this possible?

Snippet


mlazaru staff answered 2 years ago

https://mdbootstrap.com/snippets/standard/mlazaru/5222865#js-tab-view

In this code, a function iterates over all the rows and add a class based on the first cell's value.


jmztaylor pro premium commented 2 years ago

After wrapping in .on('render.mdb.datatable') it worked perfectly. Loading data via fetch so had to wait till after. Thanks!


mlazaru staff answered 2 years ago

Unfortunately, datatable does not have an option to pass classes to the rows. You would need to do that manually.


jmztaylor pro premium commented 2 years ago

Do you have an example of how to do that?


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 6.2.0
  • Device: Pc
  • Browser: Chrome
  • OS: w11
  • Provided sample code: No
  • Provided link: Yes
Tags