Topic: Datatable > Methods > format
tmrnd_estima pro premium asked 2 years 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.)
Wojciech Staniszewski staff answered 2 years 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.
Wojciech Staniszewski staff answered 2 years ago
Could you show me your format function?
tmrnd_estima pro premium commented 2 years 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' }
}
}
tmrnd_estima pro premium answered 2 years ago
tmrnd_estima pro premium answered 2 years ago
Hello, can I know when the fix will be available?
Grzegorz Bujański staff commented 2 years 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
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- 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