Topic: Datatable > Methods > format

tmrnd_estima premium asked 1 year ago

Expected behavior I want change text color based on value, (Parameter should be string or number like previously, so when I want to manipulate string value, I can update css value based on that string value)

Actual behavior I'm getting NAN value and cannot update text color to green, yellow or red, but all black :(

Resources (screenshots, code snippets etc.) enter image description here enter image description here

tmrnd_estima premium answered 1 year ago

Hello, can I know when the fix will be available?

Grzegorz Bujański staff commented 1 year ago

Currently we are focusing mainly on bug fixes. This bug is on the list of things to fix and we will try to fix it as soon as possible

Looks like the Datatable formatting only accepts number values at the moment. We will change it. The fix will be available in the next release.

tmrnd_estima premium answered 1 year ago

Can you provide some feedback based on my reply below?

Could you show me your format function?

tmrnd_estima premium commented 1 year ago

format={(field, value) => {
  if (field === 'MACHINE_HEALTH') {
    return {
      color: value === 'ONLINE' ? 'green' : 'red',
      fontWeight: 'bold',
  if (field === 'MACHINE_ID') {
    return { color: 'blue', fontWeight: 'bold' }

Please insert min. 20 characters.


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



Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB React
  • MDB Version: MDB5 4.1.0
  • Device: PC, Laptop
  • Browser: Google Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No