• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Specifying row classes in dataTables

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. You can change the class based on any condition.
 
Jamie Williams
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
umm... how? thanks for replying!
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, please help! I am unable to find anything on this anywhere!
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone out there supply some JSF code for this?
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What's brown and sticky? ... a stick. Or a tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic