Richfaces dataTable, coloring selected row on mouse click
Submitted by adevedo on Fri, 09/14/2012 - 06:40
No votes yet
RichFaces is an open source Ajax-enabled component library for JavaServer Faces, hosted by JBoss. It allows easy integration of Ajax capabilities into enterprise application development. One of the heavily used components is the DataTable which is used to display table of data based on a collection value and to define the required output columns of the resulted table.
To color the selected table row on click event, follow the below steps:
1- add selected row style to your css files or inject it in your jsf file
-
.selected-dt-row { background-color: gold !important; }
2 - the next step: in your jsf file set the datatable onrowclick event script to the following:
-
<rich:dataTable id="resultsTable" onrowclick="$(this.parentElement).find('.rf-dt-r').removeClass('selected-dt-row'); $(this).addClass('selected-dt-row');">
-
</rich:dataTable>
Thats all :)
- Add new comment
- 2343 reads
Add new comment