extjs change grid cell background based on value

后端 未结 6 1487
刺人心
刺人心 2020-12-10 06:16

I applied a renderer to my grid-column, but the background color is not changing:

renderer: function(value, meta) {
    if (parseInt(value) > 0) {
                


        
6条回答
  •  难免孤独
    2020-12-10 06:43

    Inspired by Select Smile... this worked for me:

        var myRender = function (value, metaData, record, rowIndex, colIndex, store, view) {
            if (parseInt(value) < 0) {
                metaData.attr = 'style="background-color:#ffaaaa !important;"';
            }
            return value
        };
    

    and the field

    {id: 'dta', dataIndex: 'days_to_arrival', renderer: myRender}
    

    that's it.

    ps. done under ExtJS v2.2.1

提交回复
热议问题