:: Forum >>

Can I change row style by setClass(className) rather than setStyle(attr, attrValue)?

Hi All,

I have seen the standard solution for controlling a row's style, as explained for controlling background colours in /grid.howto.style.rows/alternate-background-colors.html

The problem with this solution is that you end up with values for css attributes encoded throughoutyour javascript, rather than where they properly belong in a css file.

Does anyone know if there is a way I can do something like this instead?

Thanks :)

// function to determine if a row should have odd or even style
var alternate = function () {
return this.getRowProperty("order") % 2 ? "active-templates-row-even" : "active-templates-row-odd";
}

var row = new Active.Templates.Row;
[b]row.setClass( alternate );[/b]
obj.setTemplate("row", row);
Simon
Monday, September 5, 2005
For one, setClass requires two arguments. And secondly the way that the CSS naming convention is set in AW is .aw-name-name2 so your request for 4 qualifiers won't work. That doesn't mean that what you are proposing can't be done. Try setting up two styles:

.active-alternate-odd
.active-alternate-even

with your row styles. Then for your assignment, try this (I have not tested this):

row.setClass("alternate", this.getRowProperty("order")%2?"even":"odd");

or make the second parameter a function to return the text "odd" or "even".

Just a thought.
Jim Hunter
Wednesday, September 7, 2005

This topic is archived.


Back to support forum

Forum search