We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

How to Apply Conditional Formatting to Column on Flat Grid

Resolved
Morales, Julio César Álvaro asked on January 14, 2021

Good Day, 
I'm trying to apply a custom format to an entire column based on another column that is contained in the datasource. I'm currently getting 5 columns in the datasource, but I don't want to show the 5th one: 'HEALTH_STATUS_CL", I just want to use the value in that column. So I put the 4 I want in the columns slice section and make the formula referencing the 5th column but none of the cells is being painted in the color I selected in the condition, what can I do for it to work?
 

var pivot = $("#pivotContainer").flexmonster({
    componentFolder: "https://cdn.flexmonster.com/",
    toolbar: false, 
    report: {
        dataSource: { data: jsonTotal },
        options: {
            grid: { type: "flat" },
            configuratorActive: false,
            showAggregationLabels: false,
            showTotals: 'off',
            showGrandTotals: 'off'
        }, 
        conditions: [
            { 
                formula: "'HEALTH_STATUS_CL' = 'GOOD'",
                column: 'HEALTH_STATUS', 
                isTotal: false,
                format: {
                    "backgroundColor": "#8CE092",
                    "color": "#000000",
                    "fontFamily": "Arial",
                    "fontSize": "12px"
                }
            }
        ],
        slice: {
            columns: [
                { uniqueName: "FISCAL WEEK" },
                { uniqueName: "HEALTH_STATUS" },
                { uniqueName: "ITEM" },
                { uniqueName: "DESCRIPTION" }  
            ]
        },
        types: {
            'FISCAL WEEK': { type: 'string' },
            HEALTH_STATUS: { type: 'string' },
            ITEM: { type: 'string' },
            DESCRIPTION: { type: 'string' }
            
        } 
    }
});

2 answers

Public
Tanya Gryshko Tanya Gryshko Flexmonster January 15, 2021

Hello, Julio,

Thank you for writing to our forum.

Please kindly note that only number comparison is currently supported in condition formulas. Our team suggests changing the HEALTH_STATUS_CL column to a numeric one. For example, replace "Good" with 1 and "Not Good" with 0.

We have prepared the following example for illustration: https://jsfiddle.net/flexmonster/wgkpfc5x/

Please let us know if any further questions occur.

Kind regards,
Tanya

Public
Morales, Julio César Álvaro January 15, 2021

Excellent, everything is working on my end now, thanks a lot!

Please login or Register to Submit Answer