Extjs关于grid 行变色

    //頁面加載時創建grid
    var gdProductStock = Ext.create('Ext.grid.Panel', {
        id: 'gdProductStock',
        store: ProductStockStore,
        height: '600',
        columnLines: true,
        frame: true,
        hidden: true,
       
        columns: [
            { xtype: 'rownumberer'},
            { header: ITEMID, dataIndex: 'item_id', 150, align: 'center' },
            { header: PRODUCTID, dataIndex: 'product_id', 150, align: 'center' },
            { header: PRODUCTSTOCK, dataIndex: 'item_stock', 150, align: 'center' },
            { header: PRODUCTALARM, dataIndex: 'item_alarm', 150, align: 'center' }
        ],
        listeners: {
            scrollershow: function (scroller) {
                if (scroller && scroller.scrollEl) {
                    scroller.clearManagedListeners();
                    scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
                }
            }
        },
        viewConfig: {
            forceFit: true,

           getRowClass: function (record, rowIndex, rowParams, store) {
                if (record.data.type == "1") {
                    return 'product_stock_type';//注意这里返回的是定义好的css类;列如:(.ppp_ddd_sss div{background-color:red})定义到你页面访问到的css文件里。
                }
            }
        }
    });

原文地址:https://www.cnblogs.com/wzj-520j/p/4063013.html