Search code examples
javascriptreactjsjsonag-gridag-grid-react

custom cell reference in ag-grid in react js


i created ag-grid table using react js after that passing json data to table after passing data table look like thisenter image description here

Now i want to customize status column by some different color if status high use red if low use green else use yellow

Final output i want like this

enter image description here

How resolve this using react js for more code reference click here


Solution

  • You can conditionally apply styles to cells based on their values. Here are some ways taken from this doc example on styling cells.

    {
            
            field: 'status',
            cellClass: params => {
                return params.value === 'high' 
                         ? 'my-class-red' 
                         : params.value === 'low' 
                            ? 'my-class-green'
                            :  'my-class-yellow';
            },
        },