简体   繁体   English

使用jQuery / JavaScript在JSF中更改所选行的背景色

[英]Change selected row's background color in JSF using jQuery/JavaScript

I have a datatable which has a column with a value of commandlink. 我有一个数据表,其中有一个列,其值为commandlink。 I want to change the background color of that row, when the user click the commandlink. 当用户单击命令链接时,我想更改该行的背景色。 Any idea? 任何想法?

 <o:column id="name" width="8%" class="result_col" sortingComparator="caseInsensitiveText"> <f:facet name="header"> <h:outputText value="#{message.label_name}" /> </f:facet> <o:commandLink action="#{page.getName(name)}" onajaxend="openHistoryName();"> <h:outputText style="color:#A3A7DC;" value="Click here" /> </o:commandLink> </o:column> 

o:column does not support the class attribute. o:column不支持class属性。 Use styleClass instead. 请改用styleClass

Since you are making an AJAX call on the click of a button, you have two options: 由于单击按钮即可进行AJAX调用,因此有两个选择:

  1. Pass the new CSS styleClass as a response. 传递新的CSS styleClass作为响应。 Ex: 例如:

     <o:column styleClass='#{someManagedBean.className}'.../> 

So when you render your datatable/row, you get the updated style applied automatically. 因此,在呈现数据表/行时,您会自动应用更新的样式。

  1. Using JS/jQuery, you have to manually trigger the updated CSS on the 'onajaxend' method. 使用JS / jQuery,您必须在'onajaxend'方法上手动触发更新的CSS。 For this you would need to understand the HTML code that is generated by openfaces. 为此,您需要了解openfaces生成的HTML代码。 Based on selectors, you can apply the CSS changes. 基于选择器,您可以应用CSS更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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