Topic: Datatable > Methods > format

tmrnd_estima premium asked 10 months 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 4 months ago

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

Grzegorz Bujański staff commented 4 months 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

Wojciech Staniszewski staff answered 9 months ago

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 9 months ago

Can you provide some feedback based on my reply below?

Wojciech Staniszewski staff answered 9 months ago

Could you show me your format function?

tmrnd_estima premium commented 9 months 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