File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Specifying row classes in dataTables

 
Jamie Williams
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to specify a different coloured background for a row in a datatable based depending on the properties of my dataTable value. I am already using the 'rowClasses' property of the dataTable to produce alternating light and dark rows, but I need to specify for some elements that the row is all very dark. Is this possible?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You can change the class based on any condition.
 
Jamie Williams
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
umm... how? thanks for replying!
 
madhuri madhuri
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking forward for some help on the same. I would appreciate if anyone can put forth their thoughts how this can be done.

Thanks in Advance,
 
madhuri madhuri
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there anybody in the group who could throw some light on this . I am badly stuck here ( ( (
 
Jamie Williams
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, please help! I am unable to find anything on this anywhere!
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rowClasses can be a comma-delimited list of CSS style classes for the rows. Like we can specify multiple styles for a row by separating them with a
space in HTML. Here, after each style has been applied, they repeat.

So, we can check which list of classes or a class we need to add in rowclasses. We can alter the renderer for this. Or I think we can use JSTL for this.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can define a method like
boolean isHighlighted(){
}
to use it with JSTL.

In that method you can put your logic and use that method inside rowClasses attribute usign JSTL, something like below
if true .. then .. x-row .. else ..normal-ones

Just an idea.
[ May 26, 2006: Message edited by: Adeel Ansari ]
 
Bruce Jin
Ranch Hand
Posts: 672
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One idea is to use styleClass in addition to rowClasses. Condition styleClass to override rowClasses
 
madhuri madhuri
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bruce Jin:
One idea is to use styleClass in addition to rowClasses. Condition styleClass to override rowClasses


I have tried this approach but it does not color the entire row it just highlights the text in the cell.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by madhuri madhuri:
I have tried this approach but it does not color the entire row it just highlights the text in the cell.


Could you please send your resulted HTML code. I think it should work with <td>.
 
madhuri madhuri
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adeel Ansari:


Could you please send your resulted HTML code. I think it should work with <td>.


 
madhuri madhuri
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adeel Ansari:


Could you please send your resulted HTML code. I think it should work with <td>.


Can anybody please tell me where am i going wrong...?
 
Jamie Williams
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be really helpful if someone could just post the JSF code for the dataTable showing how to condition the rowClass/styleClass or whatever needs to be done.

If you know how to do it please share your knowledge with us!
 
Jamie Williams
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone out there supply some JSF code for this?
 
A. Dusi
Ranch Hand
Posts: 114
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I needed to highlight some rows in orange based on some condition in addition to alternating the row colors. I used this way in my code and it works for me:
For the datatable, I removed the attribute rowClasses and added the attribute rowStyleClass like "#{tableData.style}" where style is a method in my tableData(managed bean) class returning a String. This method has code like this:
public String style(){
Account styleAccount = (Account)table.getRowData();
if (styleAccount.getMyProperty.equals("condition"){

return "highlightedStyleClass";
}
else
if (table.getRowIndex() % 2 == 0){
return "evenRowStyleClass";
}
else
{
return "oddRowStyleClass";
}
}
-----------
My datatable rows represent account objects and 'table' is UIData bound to datatable.
BTW I am using Tomahawk. I have not tried with others, but I hope you get an idea with this.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic