Search code examples
javascriptextjs

Fix the grid color in ext js


I am using ext js grid to generate grids and customizing cell colors. Using a search box functionality the grid rows are filtered, but then the customized colors does not show up. Any suggestion would be helpful.


Solution

  • This article is very helpful.

    You can style any row based on the values of your data object like so:

    Ext.create('Ext.grid.Panel', { 
        ... 
        viewConfig: { 
            stripeRows: false, 
            getRowClass: function(record) { 
                return record.get('age') < 18 ? 'child-row' : 'adult-row'; 
            } 
        } 
    });
    

    The child-row & adult-row are CSS classes with a background-color.