Search code examples
tabulator

How to highlight a row depending on the cell value


I'm trying the code:

{title:"Age", field:"age", align:"left", 
 formatter:function(cell, formatterParams){
            var value = cell.getValue();
            if(value > 20){
                cell.getRow().getElement().css({    
                    "background-color": "#ffbe33"
                });
                return value;
            }else{
                cell.getRow().getElement().css({    
                    "background-color": "transparent"
                });
            return value;
    }}
    }

But get an error: TypeError: cell.getRow(...).getElement(...).css is not a function


Solution

  • If you are using Tabulator 4.0 or greater it returns a DOM Node from the getElement function so you need to use the .styles property:

     cell.getRow().getElement().style.backgroundColor = "#ffbe33";