Topic: Datatables API - by using pure HTML class and style is removed from td

ralftoermer free asked 2 years ago


Hi there,

I'm currently testing your datatables API

I'm looking for a way to use this API in pure HTML, but individual cells in a table should retain their font color and background color.

Is there a possibility?

Example:

<div class="datatable" data-mdb-max-height="calc(100vh - 170px)" data-mdb-fixed-header="true" data-mdb-clickable-rows="true" data-mdb-selectable="true" data-mdb-clickable-rows="true" data-mdb-selectable="true" data-mdb-multi="true">
    <table>
      <thead>
        <tr>
          <th>Tag</th>
          <th>Tisch</th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <tr class="o">
          <td class="m">01.01.2020 14:17:33</td>
          <td class style="background-color:#aaaa">4</td>
          <td class="color3" title="14:20:44">25</td>
          <td class="color3" title="14:22:21">27</td>
          <td class="color3" title="14:23:55">3</td>
          <td class="color1" title="14:25:32">10</td>
          <td class="color1" title="14:27:04">33</td>
          <td class="color1" title="14:28:40">10</td>
          <td class="color1" title="14:30:20">2</td>
          <td class="color3" title="14:31:55">18</td>
          <td class="color1" title="14:33:36">2</td>
          <td class="color1" title="14:35:17">13</td>
          <td class="color3" title="14:36:56">34</td>
          <td class="color1" title="14:38:33">13</td>
          <td class="m">1</td>
        </tr>              
    </tbody>
    </table>
    </div>

Thank you!

Ralf Störmer


Dawid Wajszczuk staff answered 2 years ago


Hi,

If you want special cell formatting, use format option. Here is some example form our documentation https://mdbootstrap.com/docs/standard/data/datatables/#section-cell-format.

Keep coding,
Dawid


mga premium commented 2 years ago

Hi Dawid,

Is there any way to accomplish this without format? We're migrating from another plugin to MDB and we're using datatables on pre-existing HTML - we don't have the ability to use Javascript objects and we need table rows and cells to maintain their class and data attributes.


Dawid Wajszczuk staff commented 2 years ago

Hi. Currently it is not possible. You need to use JS. But I have added a proper task to change this behavior and allow to do this via HTML.



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