How can I change the row colour in datagrid based on severity?

前端 未结 3 783
清歌不尽
清歌不尽 2020-12-15 11:24

How can I change the row colour in datagrid based upon the severity condition? I\'m new to this EXTJS topic. I used to reader to read, store to store and writer to write the

3条回答
  •  囚心锁ツ
    2020-12-15 11:37

    you can use the GridView class (Ext.grid.GridView) to manipulate the user interface of the grid. You can also the viewConfig property of the GridPanel. Here is an example:

    viewConfig: {
            //Return CSS class to apply to rows depending upon data values
            getRowClass: function(record, index) {
                var c = record.get('change');
                if (c < 0) {
                    return 'price-fall';
                } else if (c > 0) {
                    return 'price-rise';
                }
            }
        }
    

    ps: Example taken from ExtJS API documentations itself

    The price-fall and price-rise are CSS that have background colors set accordingly. eg:

    .price-fall { 
     background-color: #color;
    }
    
    .price-rise {
     background-color: #color;
    }
    

提交回复
热议问题