Card styling for datatable rows


Topic: Card styling for datatable rows

somboo asked 4 years ago

Expected behavior I'd like to use datatable, but want the rows of some, and not all, tables on the site to be styled as cards. I suspect I could achieve this by adding the card class to row at the css level, but then it would apply to all of my rows and not just some.

Actual behavior I can't find a way to add style classes to rows on a per datatable basis. Is this not possible or am I missing something?

Resources (screenshots, code snippets etc.)


Krzysztof Wilk staff answered 4 years ago

Hi!

I'm afraid there is no feature to add classes to the rows in data tables right now.

You can use basic tables (https://mdbootstrap.com/docs/standard/data/tables/) or use some custom JavaScript code to achieve your goal. Example code should look like below:

document.querySelectorAll('tr').forEach((tr) => tr.classList.add('card'));

Hope it'll meet your expectations :)

Best regards


somboo commented 4 years ago

That is an excellent idea. Thank you.


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: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: 2.2.1
  • Device: All
  • Browser: All
  • OS: All
  • Provided sample code: No
  • Provided link: No