Romick
8 Dec 2011, 3:15 AM
Hi!
I have treePanel with two columns. I need to change background-color only in the first column, but color is different and cames from treeStore.
I found two ways29881 but both is bad.
First-one:
using renderer metadata
{
text: '#',
dataIndex: 'col1',
width: 30,
renderer: function colorExampleRenderer(val, metadata, record, rowIndex){
metadata.style = 'background: red';//record.get('mycolor');
//metadata.tdCls = 'myColor';
return val;
}
but background color covered only in <div> element not in <td>
Second-one:
I set up tdCls property
{
text: '#',
dataIndex: 'col1',
width: 30,
tdCls: 'x-change-cell'
}
And use view config of the tree:
viewConfig: {
getRowClass: function(record, index) {
var c = record.get('change');
if (c < 0) {
return 'price-fall';
} else if (c > 0) {
return 'price-rise';
}
}
},
Also set css styles:
.price-fall .x-change-cell {
background-color: #FFB0C4;
color:red;
}
.price-rise .x-change-cell {
background-color: #B0FFC5;
color:green;
}
But this time i havent posibility to change background color dependence of color in record, becouse here i dont know how to create ccs style dynamicly.
Has anyone solved this problem? I need your help.
I have treePanel with two columns. I need to change background-color only in the first column, but color is different and cames from treeStore.
I found two ways29881 but both is bad.
First-one:
using renderer metadata
{
text: '#',
dataIndex: 'col1',
width: 30,
renderer: function colorExampleRenderer(val, metadata, record, rowIndex){
metadata.style = 'background: red';//record.get('mycolor');
//metadata.tdCls = 'myColor';
return val;
}
but background color covered only in <div> element not in <td>
Second-one:
I set up tdCls property
{
text: '#',
dataIndex: 'col1',
width: 30,
tdCls: 'x-change-cell'
}
And use view config of the tree:
viewConfig: {
getRowClass: function(record, index) {
var c = record.get('change');
if (c < 0) {
return 'price-fall';
} else if (c > 0) {
return 'price-rise';
}
}
},
Also set css styles:
.price-fall .x-change-cell {
background-color: #FFB0C4;
color:red;
}
.price-rise .x-change-cell {
background-color: #B0FFC5;
color:green;
}
But this time i havent posibility to change background color dependence of color in record, becouse here i dont know how to create ccs style dynamicly.
Has anyone solved this problem? I need your help.