View Full Version : Programatically Changing Row Style with Grid 1.0

20 Feb 2007, 9:29 PM
What is the best way to change the row style in a grid based on a value in the record? I was using custom renderers, but figure there has to be an cleaner way than that.


20 Feb 2007, 11:06 PM
Each column can have renderers. That's the standard approach.

In 1.0, you have new ways to style via css classes instead of having to generate markup:

function formatFoo(value, p, record, rowIndex, colIndex, store){ // lots of data available
p.css = value < 0 ? 'neg-data' : ''; // <-- New! add css classes to the cell
p.attr = 'ext:qtip="This is a QTip!"'; // <-- New! add custom attributes
return value;

The real power is that you can modify the cell template and create your own new cell parameters (careful to leave it similar or update initElements as well).

Note: The qtip example above depends on Ext.QuickTips.init() being called on page load.