Hello we are using jsf jsr168 portlets. When the portlet is rendered we need the first row of the datatable to be selected by default
Can any one help on how to achieve this?(Please provide code)
Printable View
Hello we are using jsf jsr168 portlets. When the portlet is rendered we need the first row of the datatable to be selected by default
Can any one help on how to achieve this?(Please provide code)
If you are using a RowSelect component withing the dataTable, selection will be rendered according to data in the model. That is, if your RowSelect component is bound to an array/collection that indicates that the 1st row is selected, then that's how it will be rendered.
hi yury,
thanks,
well we are not using rowselect.Just wondering is there a way to get the first row in backing bean and change the style.Or get it from UIViewRoot in Portlet and change the row style.
Just wondering.
thanks
dataTable has only one way of styling rows "out of the box" -- that is using rowClasses attribute that takes a comma-separated list of CSS classes. Those classes get applied to all rows "in a loop", ie if you provide two classes, then you'll get 1st class applied to all odd rows and the 2nd class applied to all even rows.
Given that, you could provide a list of classes containing as many elements as there are rows, with 1st class being different. Something like rowClasses="firstRowClass,rowClass,rowClass,rowClass,rowClass".
Another approach would be to write a small bit of JavaScript that changes the style of the 1st TR in the TABLE.
Hi yury,
thanks again.
I am not sure how i can use the second approach.This is because we need the row to be selected by default.Which means when the jsp is rendered we need to use events like onload.However with portlets we cant use onload event.
I will try the first approach and get back.
thnx