简体   繁体   中英

how to highlight particular row in JSF datatable

I am new to JSF. I need to know how to highlight a particular row in JSF data-table or a particular field in a JSF data-table. Please any one give me a solution. Thanks in advance.

您可以通过EL表达式(例如styleClass="#{condition ? 'old' : 'new'}"使用条件着色。

Datatable row can be highlighted when mouse move over it or when it is selected. There are different actions. Both of them are implemented in following code (RichFaces 4.3.x).

xhtml code:

<rich:dataTable var="rs" value="#{retailerAction.retailerList}"
    rows="#{referenceData.recordsPerPage}" rowClasses="oddrow, evenrow"
    onrowclick="dataTable.onRowSubmit(this, 'selected-dt-row');"
    onrowmouseover="dataTable.onRowMouseOver(this, 'gridmouseover');"
    onrowmouseout="dataTable.onRowMouseOut(this, #{currRow}, 'oddrow', 'evenrow')"
    rowKeyVar="currRow" style="width: 100%">
</rich:dataTable>

Special style is used for selected row:

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

Other style is used for row under cursor :

.gridmouseover {
    background-color: #E4F7FD;
    cursor: pointer;
}

Zebra styles:

.evenrow {
    background-color: #F5F5F5;
}

.oddrow {
    background-color: #FFFFFF;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM