Number formatting in Datatable


Topic: Number formatting in Datatable

Carl Malouf asked a year ago

Expected behavior Set a particular format required of datatable columns (e.g. number in currency format ($XXX,XXX.00) thousand separators, 2 decimal places) and ability to right-align those columns individually.

Actual behavior No obvious ability to apply horizontal alignment by column or specify a formatter function.

Resources (screenshots, code snippets etc.) Similar ability to https://bootstrap-table.com/ would be good. They allow specification of a 'data-formatter' attribute per column which can call a JS formatter function. Also allows for setting a horizontal alignment option per column.


Krzysztof Wilk staff answered a year ago

Hi!

Thanks for your suggestion! It would be nice to have these features in our package, so we'll try to implement them as soon as possible :)

Best regards


tillmr pro premium answered 7 months ago

is there any update regarding this problematic?


Marcin Luczak staff commented 7 months ago

MDB5 Datatables allows custom cell formatting: https://mdbootstrap.com/docs/standard/data/datatables/#section-cell-format

Keep coding, Marcin


futureweb pro premium priority commented 2 months ago

Are there any predefined formats like date, currency?


Marcin Luczak staff commented 1 months ago

Hi @futureweb,

We do not provide any predefined formats for date or currency as this can be achieved with just JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat

Keep coding, Marcin


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: Other
  • MDB Version: -
  • Device: Computer
  • Browser: Edge
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes