PDA

View Full Version : how to change bgcolor of one column in a specific in a grid



humpdi
9 Mar 2007, 6:38 AM
hey guys!

one question, how could a change the backgroundcolor of one column in a specific row in my grid?
have nothing found about this..

should look like this:

-------|---------------|----------------|
-------|---------------|----------------|
-------|-- bg=red --|----------------|
-------|---------------|----------------|
-------|---------------|- bg=green -|

Animal
9 Mar 2007, 9:20 AM
Where containerId contains the ID of the GridPanel's element, and colNo is the zero-based column number:



Ext.util.CSS.updateRule("#" + containerId + " .x-grid-cell-" + colNo, "background-color", "green");

jack.slocum
10 Mar 2007, 1:14 AM
Or, if using Ext 1.0, add a css class to the cell using the template parameters in column renderer:


function renderFoo(value, p, record){
if(...){
p.css = 'some-css-class-with-bg-color';
}
return value;
}

humpdi
10 Mar 2007, 3:09 AM
thank you 2!

mdelanno
24 Apr 2007, 10:38 AM
In the code of Animal, .x-grid-cell should be replaced by .x-grid-td. It works, but it changes also the header.

Animal
25 Apr 2007, 2:41 AM
OK,



Ext.util.CSS.updateRule("#" + containerId + " .x-grid-col-" + colNo, "background-color", "green");


Works for one column of data.



Ext.util.CSS.updateRule("#" + containerId + " .x-grid-cell-" + rowIndex + "-" + colNo, "background-color", "green");


Works for one individual cell.