Reputation: 19993
I'd like to specify the css class that the Tapestry Grid component assigns to the TH and TD tags in a column. Is this possible?
Upvotes: 3
Views: 1619
Reputation: 27994
And the long answer is yes!
If the class attributes, mentioned in Steve Enyon's answer, are not enough you can decorate the DOM after the grid has rendered via a mixin. I have created a GridDecorator mixin here which can decorate TR
and TD
elements based on the value in the cell / row. In my example I add onclick
and style
attributes to the DOM. You could easily tweak the mixin to decorate TH
elements with a GridHeaderCellDecorator and add class
attributes where necessary.
My 2p, I think that the Grid is long overdue for an overhaul and that customisations like this should be much easier than they are.
Upvotes: 3
Reputation: 5139
The short answer is no.
What Tapestry does do though is give each column a unique css class based on the property it represents. You can then style this class any way you want.
For example, if you had a Grid
of User
classes:
public class User {
public String firstName;
public String lastName;
}
<t:grid source="users" />
Tapestry would produce HTML similar to:
<table>
<thead>
<tr>
<th class="firstName">First Name</th>
<th class="lastName">Last Name</th>
</tr>
</thead>
<tbody>
...
<tr>
<td class="firstName">Traci</td>
<td class="lastName">Lords</td>
</tr>
...
</tbody>
</table>
See the CSS
section at the bottom of the Grid API page for more details.
If you have some common styling that you'd like to apply to specific columns, and you happen to be using less, then you could use less mixins
(not to be confused with Tapestry mixins). From the Less website:
Mixins allow you to embed all the properties of a class into another class by simply including the class name as one of its properties
Upvotes: 1