Topic: Datatable > Methods > format

tmrnd_estima premium asked 1 month 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

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 month ago

Can you provide some feedback based on my reply below?

Could you show me your format function?

tmrnd_estima premium commented 1 month 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

  • User: 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