javascriptextjsdatagridextjs4

In ExtJS, how to add a custom CSS class to data grid rows?


How do I add custom CSS classes to rows in a data grid (Ext.grid.Panel)?

I'm using ExtJS 4.0.


Solution

  • The way to do it is to define viewConfig on the grid:

    Ext.create('Ext.grid.Panel', {
        ...
    
        viewConfig: {
            getRowClass: function(record, index, rowParams, store) {
                return record.get('someattr') === 'somevalue' ? 'someclass' : '';
            }
        },
    
        ...
    });