Search code examples
javascriptextjsbackground-colorsencha-architect

Setting gridview column background dynamically


I'm using Ext JS 4.0 and the Sencha Architect 4.1

I want to set the column background of each column based on a value of the corresponding record.

I know how to change the cell background using a renderer. But I don't know how to do this for the whole column because I don't want to set a renderer for each cell in my gridview.

Is there a way to set the background for the whole column?


Solution

  • I solved it this way:

    In the Site.css I added a style like this

    .custom-row .x-grid-cell {
        background-color: #ffe2e2;
    }
    

    and in my Ext.grid.View I added the getRowClass method like this

    viewConfig: {
        getRowClass: function(record, rowIndex, rowParams, store) {
            var isConditionMatching = ....
    
            if(isConditionMatching ){
                return 'custom-row';
            }
        },