• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

highlight back ground of a row in datatable

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its a jsf related query. i have got a table i want to highlight a whole row in the data table. this is to be done when i select a particular link in one of the rows. so the selected row should get highlighted. how do i achieve this. any pointers? Thanks in advance.
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well sounds like a simple question, but it isn't.

You can use the rowStyle attibute to create rowStyles at runtime. i.e. bind that attribte to backng bean and at run time create style for each row(and hence for the selected row). We are using this approach only.

you have to check may things like whether
- you are using sorting in data table .. then you have to check that after sort the style doesnt break.
- you are using "next"/ "previous" button in datatable to scroll.
- you are allowing mutiple selects also ...
etc. etc.

You can also check out other implementations like myfaces etc. , may be they are providing this am not sure though.
 
vikram s
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the early reply i will try it out. but is there an attribute rowStyle for datatable? anyways thanks, and a Happy New Year.
 
bronco
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's actually called rowClasses. Note that the way this works is that it repeats the classes you specify. So if you say:

rowClasses="foo,bar"

...you'll get:

foo
bar
foo
bar

...so I think you'd need to specify a class for each row. something like:

rowClasses="normal,normal,normal,highlighted,normal"

HTH
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dave Wood:
It's actually called rowClasses.
HTH



Ooops, yeah I meant rowClasses only
 
vikram s
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its fine that i define rowClasses. But how do i do it dynamically.
 
Dave Wood
bronco
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't tried this, but you should be able to do something like:


Where your backing bean has:
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The getRowData() method of the HtmlDataTable class returns the selected row (if any). Now based on selected row's content, you can set the row style.

e.g. of your normal style is "rows" and highlighted style is "highlight",
use getRowData() method to see which row is selected, now if it's third row, your rowClasses should be rowClasses="rows,rows,highlight,rows,..."
[ January 03, 2005: Message edited by: K Varun ]
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now if in your table, two rows are exactly same : this approach may fail

If you highlight one of those two "same" rows, at the server side you wont be able to find which one to highlight.
To overcome this, use a unique identifier with each row and check on that.
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic