2012-09-10 82 views
4

我試圖突出顯示在rich:dataGrid中的選擇。這就像當我單擊dataGrid中的鏈接時,將打開一個modalPanel供用戶選擇圖像,並且當關閉模式面板時,新選定的圖像將在dataGrid中刷新。爲此,我正在重新渲染modalPanel中的dataGrid。這工作正常。現在,我想突出顯示用戶選擇。當我使用下面的rich:jquery時,它會突出顯示,但隨後會出現modalPanel彈出窗口和重新渲染。所以突出顯示的行就是它的原創自我。使用Richfaces突出顯示選擇JQuery

JSF:

<rich:dataGrid value="#{startupBean.choiceKeys}" var="mapEntry" columns="#{startupBean.rowSize}" styleClass="rich-table"> 


           <rich:dataGrid id="choiceSub" styleClass="rich-table" value="#{mapEntry.value}" var="ObjBO" columns="2"> 
             <f:facet name="header"> 
              <h:outputText value="Choice:#{mapEntry.key}"></h:outputText> 
             </f:facet> 
           <h:panelGrid columns="2" border="0" styleClass="className"> 
           <rich:panel> 
            <f:facet name="header"> 
            <a4j:commandLink id="objs" action="#{startupBean.getCategory}" reRender="materialTree" oncomplete="Richfaces.showModalPanel('selectMaterial',{top:'100px', left:'400px', height:'450px', width:'450px'});" > 
             <h:outputText value="#{ObjBO.displayName}" binding="#{startupBean.outTxt}"/> 
              <f:setPropertyActionListener target="#{startupBean.key}" value="#{mapEntry.key}" /> 
             </a4j:commandLink> 
            </f:facet> 
             <h:graphicImage width="50" height="50" id="choice" alt="jsf-sun" url="#{ObjBO.color_url}" value="#{ObjBO.color_url}"> 
             </h:graphicImage> 
             </rich:panel> 
           </h:panelGrid> 
           </rich:dataGrid> 
           <rich:jQuery selector="#choiceSub tr" query="click(function(){jQuery(this).addClass('active-row')})"/> 
         </rich:dataGrid> 

CSS:

.active-row { 
    background-color: red; 
} 

有沒有做任何其他方式?請讓我知道。 PS:我使用的是JSF2.0,Richfaces 3.2,Apache Tomcat 7,Java 1.7。

感謝, 簡

+0

RichFaces 3.2或4.2? –

+0

它是RichFaces 3.2。使用4.X版本時遇到一些問題。 – Jane

回答

1

當你重新呈現的元素,它就會由服務器生成的新內容取代。即任何之前已經動態應用的其他格式或更改(如rich:jQuery中的jQuery)會丟失。另請參閱rich中的問題描述:jQuery手冊http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_jQuery.html

基本上,您必須在ajax返回後再次應用行高亮。請評論,如果你需要額外的說明。