EXTJS 5树状网格自定义行css

EXTJS 5 Tree grid custom row css

本文关键字:自定义 css 网格 EXTJS      更新时间:2023-09-26

我有一个树网格,我想更改父行和子行的css(在我的情况下是背景色)。我做了一些css类,并使用了viewConfig.getRowClass方法,但它不适用于悬停和选择。

以下是我的问题:https://fiddle.sencha.com/#fiddle/jl1

这是我的树网格:

var tree = Ext.create('Ext.tree.Panel', {
    renderTo: Ext.getBody(),
    title: 'TreeGrid',
    rootVisible: false,
    width: 300,
    height: 250,
    store: store,
    viewConfig: {
        getRowClass: function(record, index) {
            if (record.get('name').indexOf('Group') != -1) {
                return 'row-parent';
            }
            return 'row-child';
        }
    },
    columns: [{
        xtype: 'treecolumn',
        text: 'Name',
        dataIndex: 'name',
        width: 150
    }, {
        text: 'Description',
        dataIndex: 'description',        
        width: 150
    }]
});

这是我的css:

.row-parent .x-grid-cell {    
    background-color: #c1ddf1 !important;
}
.row-parent .x-grid-row-over .x-grid-cell {
    background-color: #3da5f5 !important;
}
.row-parent .x-grid-row-selected .x-grid-cell {
    background-color: #ff0 !important;
}
.row-child .x-grid-cell {
    background-color: #e2eff8 !important;
}
.row-child .x-grid-row-over .x-grid-cell {
    background-color: #85c4f5 !important;
}
.row-child .x-grid-row-selected .x-grid-cell {
    background-color: #ff0 !important;
}

你知道为什么选择和悬停css不起作用吗?

提前感谢=)!

.row-parent .x-grid-cell {
    background-color: #c1ddf1 !important;
}
.x-grid-item-over .row-parent  .x-grid-cell {
    background-color: #3da5f5 !important;
}
.x-grid-item-selected .row-parent .x-grid-cell {
    background-color: #ff0 !important;
}
.row-child .x-grid-cell {
    background-color: #e2eff8 !important;
}
.x-grid-item-over .row-child .x-grid-cell {
    background-color: #85c4f5 !important;
}
.x-grid-item-selected .row-child .x-grid-cell {
    background-color: #ff0 !important;
}