【问题标题】:How to set colour to f:selectItem in primefaces?如何在primefaces中将颜色设置为f:selectItem?
【发布时间】:2015-05-11 13:47:33
【问题描述】:

如何在 primefaces 中为 selectOneMenu 设置颜色?

 <p:selectOneMenu id="col" value="#{projectsController.selected.listColor}">
                    <f:selectItem itemLabel="Activity" itemValue="1"  class="redBackGroundColor"/>
                    <f:selectItem itemLabel="Activity1" itemValue="2" class="blueBackGroundColor"/>
                    <f:selectItem itemLabel="Activity2" itemValue="3" class="greenBackGroundColor"/>

                </p:selectOneMenu>

这是我的 CSS

.redBackGroundColor{
    background-color:red;        
}

(当然还有蓝色和绿色..) 但它不影响primeface的行为。

【问题讨论】:

标签: css jsf primefaces


【解决方案1】:

在 JSP 中是不可能的 但你可以在 javascript 中做到这一点

例如:

      $(this).children("tbody").children("tr").each(function () {
              if ($(this).children("td").children("input").val() == 1) {
                       $(this).addClass("redBackGroundColor");
                } 

..... 这对我有用。

【讨论】:

  • 与 selectOneMenu 中的 selectItems 的“高级”显示相比,这是一个糟糕的复杂解决方法
猜你喜欢
  • 1970-01-01
  • 2012-03-21
  • 2021-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-16
  • 1970-01-01
  • 2013-01-27
相关资源
最近更新 更多