Topic: Datatable format attribute

AHOY priority asked 1 month ago


When using datatable, is there an option for setting a column's format using a data attribute. My datatable is an HTML table so I'd rather not have to switch the initialization of the datatable to JavaScript using new mdb.Datatable(...).


mlazaru staff commented 1 month ago

What exactly do you want to do with the columns?

There is a column options section in our docs, let me know if there is a solution of your problem:

https://mdbootstrap.com/docs/standard/data/datatables/#api-section-column-options


AHOY priority commented 1 month ago

I'd like to be able to better control the formatting of the cell (using a data attribute equivalent of a column's JavaScript "format" option) to address issues with sorting of dates in MM/DD/YYYY format and other columns that cannot be sorted alphabetically. For example: https://mdbootstrap.com/docs/standard/data/datatables/#section-cell-format. My program currently outputs an HTML table so I'm hoping there's an option to set the format via a data attribute, e.g. data-mdb-format="formatCellFunction" or data-mdb-format="javascript:function() { ... }". Attempting to do so results in a JavaScript error that the format is a string and not a function.


mlazaru staff answered 1 month ago


Unfortunately, there is no way to pass format through the data attribute or any other attribute to perform the expected actions. Any cell formatting only works if the data is injected from JS.



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: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 5.0.0
  • Device: Desktop
  • Browser: Chrome 106.0.5249.119
  • OS: Mac OS 11.6
  • Provided sample code: Yes
  • Provided link: No