JkSuf
JkSuf

Reputation: 343

EXTJS 5 Tree grid custom row css

I have a tree grid, and I would like to change css (in my case background color) of parent rows and child rows. I did some css class and used the viewConfig.getRowClass method but it doesn't work for hover and selection.

Here is the fiddle of my problem: https://fiddle.sencha.com/#fiddle/jl1

This is my tree grid:

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
    }]
});

And this is my 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;
}

Do you know why the selection and hover css does not work ?

Thanks in advance =) !

Upvotes: 1

Views: 1725

Answers (1)

rangelovg
rangelovg

Reputation: 71

.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;
}

Upvotes: 2

Related Questions