Richfaces dataTable, coloring selected row on mouse click

adevedo's picture
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

  1. .selected-dt-row { background-color: gold !important; }

2 - the next step: in your jsf file set the datatable onrowclick event script to the following:

  1. <rich:dataTable id="resultsTable" onrowclick="$(this.parentElement).find('.rf-dt-r').removeClass('selected-dt-row'); $(this).addClass('selected-dt-row');">
  2. </rich:dataTable>

Thats all :)

Add new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.
By submitting this form, you accept the Mollom privacy policy.