Reputation: 101
I'm trying to change the color of a tabulator cell based on the input of the cell. My first step was to just simply try and change the color of the cell. Run the following code, I see the following
function testFormatter(cell, formatterParams) {
cell.getElement().style.backgroundColor = "#A6A6DF";
}
Here is what my table looks like after using the cell formatter
I apologize if I get back to you late. This is my first StackOverflow post and I don't know how long replies usually take to come in.
Upvotes: 3
Views: 4113
Reputation: 121
For all cells:
formatter: function (cell) {
let val = cell.getValue();
let el = cell.getElement();
el.style.backgroundColor = "#A6A6DF";
return val;
}
For a cell that math condition:
formatter: function (cell) {
let val = cell.getValue();
let el = cell.getElement();
if (val == "some text") {
el.style.backgroundColor = "#A6A6DF";
}
return val;
}
Upvotes: 1
Reputation: 101
I figured out the solution. The documentation doesn't say it, but custom formatters HAVE to return a value in some way, shape or form.
So the code to rectify the issue would simply be the following:
function testFormatter(cell, formatterParams) {
var bvid = cell.getValue();
cell.getElement().style.backgroundColor = "#A6A6DF";
return bvid
}
Upvotes: 5