Thanks Greg. I had implemented the solution where I was setting the rowClasses using a comma-delimited string of styles but obviously your solution is a million times better. I guess I was looking at the reference implementation docs not the tomahawk one so I didn't spot the rowStyleClass attribute.

Thanks again

Jean





"Lindholm, Greg" <[EMAIL PROTECTED]>

22/03/2006 19:20

Please respond to
"MyFaces Discussion" <[email protected]>

To
"MyFaces Discussion" <[email protected]>
cc
Subject
RE: Style for row in datatable





Yes, it's EL so you can use any valid _expression_.
Also, you can test any property in your row object it doesn't have to be
a displayed column.


-----Original Message-----
From: James Reynolds [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 1:08 PM
To: MyFaces Discussion
Subject: RE: Style for row in datatable

So you have a column in your data that determines the row style based on
the conditional statement in your rowStyleClass (pretty cool, I didn't
know you could code an if statement that way).

Is it also possible to evaluate the value of a numeric field?  Such as:
...
rowStyleClass="#{myRow.totalRevenue gt 0 ?
'BlackFontStyle':'RedFontStyle'}"
...


-----Original Message-----
From: Lindholm, Greg [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 10:51 AM
To: MyFaces Discussion
Subject: RE: Style for row in datatable

Yes, it's easy using <t:dataTable>

<t:dataTable
                id="myTable"
rowStyleClass="#{myRow.active ? 'ActiveRowStyle':'InactiveRowStyle'}}"
                var="myRow"
                value="#{myBean.values}">



-----Original Message-----
From: James Reynolds [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 12:37 PM
To: MyFaces Discussion
Subject: RE: Style for row in datatable


I have been interested in this as well.  One suggestion that has been
offered in the past is to bind the dataTable row styles to a bean value.
The bean value would be a comma delimited string of class names, one for
each row.  Obviously, you would need to build that list dynamically
based on some aspect of your data.  I haven't tried it yet so I can't
provide any feedback on its success, but maybe the idea will help you.

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 5:19 AM
To: [email protected]
Subject: Style for row in datatable



Hi,

Is it possible to apply a style to a row in a datatable dynamically? For
example, I might have a datatable showing a list of numbers and I would
want the rows containing negative numbers to be red and the positive
numbers to be blue. I want to apply the style to the entire row (<tr>)
not just the contents.

I believe this cannot be achieved using the rowClasses attribute of the
datatable.

Is there any way of achieving this?

Thanks

Jean




Reply via email to