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.
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.
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 ]
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.
- Varun
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