PDA

View Full Version : Changing the color of a cell in a grid



MmarcoM
1 Sep 2009, 2:34 AM
Hello all,
i have written an extjs app where i am loading data into a GridPanel.
the data loaded contains columnX, columnY and columnZ

I want to do so that if the value of columnX is different from teh value of columnY, the
background of columnX and columnY should be red

anyone coudl help me in achieving that?

thanks in advancea nd regards
marco

Animal
1 Sep 2009, 2:42 AM
Use a combination of GridView.getRowClass, and ColumnModel's column IDs.

dlbjr
1 Sep 2009, 5:00 AM
{
header: 'Column X',
dataIndex: 'columnX',
hideable: false,
sortable: true,
width: 75,
align: 'right',
renderer: function(data, cell, record, rowIndex, columnIndex, store) {
if (data.toString().trim() != record.get('columnY').toString().trim()) {
cell.attr = 'style="background-color: #ff0000;"';
}
return data;
}
}

MmarcoM
1 Sep 2009, 6:06 AM
thank you dlbjr... that did it!!!!

regards
marco