2017-05-23 236 views
0

在我的數據表中,根據列「Délai動作」,當沒有日期時,其他列必須爲紅色。 根據日期,最後一列有一個黃色/橙色/紅色球形圖標。 那麼如何更新行,然後顯示紅色的列和不對應的顏色球?如何在單元格編輯後更新primefaces數據錶行?

我嘗試不同的東西,如:

<p:ajax event="cellEdit" listener="#{prospectionForm.enregistrer}" update="cmpTableMandats"/> 

或者也是我enregistrer()方法: RequestContext.getCurrentInstance().update(table.getClientId(FacesContext.getCurrentInstance()) + ":" + event.getRowIndex() + ":objet");

下面是數據表:

<p:dataTable id="cmpTableMandats" value="#{prospectionForm.listMandats}" 
         var="mandat" rows="50" rowKey="#{mandat.id}" 
         scrollable="true" scrollHeight="440" 
         editable="true" editMode="cell" 
         emptyMessage="#{msg['AucuneDonneeAAfficher']}" 
         paginator="true" paginatorPosition="bottom" 
         paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
         rowsPerPageTemplate="50,100,200,300" 
         style="margin-top:20px"> 

         <p:ajax event="cellEdit" listener="#{prospectionForm.enregistrerModification}" update=""/> 

         <p:column headerText="#{msg['Numero']}" style="width:12%"> 
          <h:outputText value="#{mandat.numero}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
         </p:column> 

         <p:column headerText="#{msg['AbregeDirecteur']}" style="width:4%"> 
          <h:outputText value="#{mandat.coordinateur.initiales}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
         </p:column> 

         <p:column headerText="#{msg['AbregeChefDeProjet']}" style="width:4%"> 
          <h:outputText value="#{mandat.chefProjet.initiales}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
         </p:column> 

         <!-- Affiche la localité pré-enregistrée ou la localité libre --> 
         <p:column headerText="#{msg['Localite']}" style="width:15%"> 
          <h:outputText value="#{mandat.listMandatLocaliteToString}" 
           rendered="#{not empty mandat.listMandatLocalite}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
          <h:outputText value="#{mandat.localiteLibre}" 
           rendered="#{not empty mandat.localiteLibre}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
         </p:column> 

         <p:column headerText="#{msg['AbregeMaitreOuvrage']}" style="width:20%"> 
          <h:outputText value="#{mandat.listMandatIdentiteToString}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
         </p:column> 

         <p:column headerText="#{msg['Objet']}" style="width:30%"> 
          <h:outputText id="objet" value="#{mandat.objet}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
         </p:column> 

         <p:column headerText="#{msg['CHF']}" style="width:10%; text-align:right"> 
          <p:cellEditor> 
           <f:facet name="output"> 
            <h:outputText value="#{mandat.montantHonorairesFrais}" rendered="#{mandat.montantHonorairesFrais != 0.0}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"> 
             <f:convertNumber pattern="#,##0.00" locale="fr_CH"/> 
            </h:outputText> 
           </f:facet> 
           <f:facet name="input"> 
            <p:inputText value="#{mandat.montantHonorairesFrais}" 
              converterMessage="Cannot convert to double."> 
             <f:convertNumber pattern="#,##0.00" locale="fr_CH"/> 
            </p:inputText> 
           </f:facet> 
          </p:cellEditor> 
         </p:column> 

         <p:column headerText="#{msg['EtapeActuelle']}" style="width:13%"> 
          <p:cellEditor> 
           <f:facet name="output"> 
            <h:outputText value="#{mandat.fluxProspectionCi.nom}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
           </f:facet> 
           <f:facet name="input"> 
            <p:selectOneMenu value="#{mandat.fluxProspectionCi}"> 
             <f:selectItems value="#{prospectionForm.listFluxProspection}"/> 
            </p:selectOneMenu> 
           </f:facet> 
          </p:cellEditor> 
         </p:column> 

         <p:column headerText="#{msg['Remarque']}" style="width:30%"> 
          <p:cellEditor> 
           <f:facet name="output"> 
            <h:outputText value="#{mandat.remarqueProspection}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"/> 
           </f:facet> 
           <f:facet name="input"> 
            <p:inputTextarea value="#{mandat.remarqueProspection}"/> 
           </f:facet> 
          </p:cellEditor> 
         </p:column> 

         <p:column id="cmpDateAction" headerText="#{msg['Delai']} #{msg['Action']}" style="width:10%"> 
          <p:cellEditor> 
           <f:facet name="output"> 
            <h:outputText value="#{mandat.dateActionProspection}" styleClass="#{(mandat.fluxProspectionCi eq 'ETABLIR_OFFRE' or mandat.fluxProspectionCi eq 'A_RELANCER') and mandat.dateActionProspection == null ? 'red' : null}"> 
             <f:convertDateTime pattern="dd.MM.yy"/> 
            </h:outputText> 
           </f:facet> 
           <f:facet name="input"> 
            <p:calendar id="cmpDate" 
             value="#{mandat.dateActionProspection}" showOn="true" 
             pattern="dd.MM.yyyy" mask="true" locale="fr" styleClass="myInputClass"> 
            </p:calendar> 
           </f:facet> 
          </p:cellEditor> 
         </p:column> 

         <p:column headerText="" style="width:10%;"> 
          <h:graphicImage id="un" rendered="#{mandat.dateProspectionDepassee}" value="/resources/images/icones/rwb/ball_red.png"/> 
          <h:graphicImage id="deux" rendered="#{mandat.dateProspectionAujourdhui}" value="/resources/images/icones/rwb/ball_orange.png"/> 
          <h:graphicImage id="trois" rendered="#{not mandat.dateProspectionDepassee and not mandat.dateProspectionAujourdhui and mandat.dateProspectionDans5JoursouMoins}" value="/resources/images/icones/rwb/ball_yellow.png"/> 
         </p:column> 

         <f:facet name="footer"> 
          #{fn:length(prospectionForm.listMandats)} #{msg['MandatsEnregistres']} 
         </f:facet> 
        </p:dataTable>` 

但是,沒有什麼工作正常 enter image description here

在此先感謝

Primefaces 6.0/2.3 JSF

+0

你看到這個帖子[按條件顏色行(https://stackoverflow.com/questions/42768759/coloring-a-case-in-a-primefaces-datatable-by-a -condition/42786061#42786061)?!? –

+0

是的,我沒有,但問題是「如何單元格編輯後更新primefaces數據表中的行?」。謝謝 – fipro28

回答

1

請使用p:remoteCommand

說明可以在此answer通過@BalusC

中找到更多有關p:remoteCommand,請參閱Primefaces展示RemoteCommand

問候,

+0

完美,謝謝:-) – fipro28

相關問題