PDA

View Full Version : How do you apply a style of to a particular cell on a Grid?



timmah
6 Oct 2010, 12:13 PM
I've defined a new style in CSS and would like to apply it to a particular cell in a Grid. Could someone please provide a code example on how to accomplish this.

Thanks !

sven
6 Oct 2010, 12:19 PM
This depends on what you need exactly.

You can use a GridCellRenderer that returns markup that contains your className.

timmah
6 Oct 2010, 12:26 PM
Basically, I would like to apply different style to a cell depending on the value within a cell. I have positive numbers values should be green and negative should be red. What would you suggest ? Do it thru a cell renderer ?

sven
6 Oct 2010, 12:28 PM
Than you need to use the GridCellRenderer. There is even an example for this doing exactly what your example is http://www.sencha.com/examples/explorer.html#basicgrid

timmah
6 Oct 2010, 1:00 PM
Excellent. Last question... the example shows the hard coded way of applying a style. What would be the way to reference a style defined in a css file? Thanks !

sven
6 Oct 2010, 1:18 PM
simple use a classname and put it into the markup.