2017-05-30 80 views
0

我有一個primefaces確定年代的問題,我有一列,前一個過濾器,高效過濾器是正確顯示像這樣我的DataTable中的結果:號碼:數據表顯示AJAX更新後錯誤地

good display

當我選擇的過濾器,過濾器的組合框正確poulated:

Display of the filter list

一個很快我選擇的過濾器項目,結果就被完全過濾,但我的顯示器數據表是這樣的:

Wrong display

我剛纔看到誰應該顯示的結果在一個DataTable但該表已經一去不復返了。

的代碼看起來不錯,我看不出哪裏出了問題:

<p:outputPanel autoUpdate="true" class="ui-g-12"> 
       <div class="card"> 
        <h1>Gestion des noeuds</h1> 
        <h:form> 

         <p:dataTable value="#{nodeController.nodes}" 
            var="node" 
            tableStyle="table-layout: auto;" 
            rowKey="#{node.nodeId}" 
            paginator="true" 
            paginatorPosition="bottom" 
            paginatorAlwaysVisible="false" 
            rows="15" 
            widgetVar="nodeTable" 
            filteredValue="#{nodeController.filterNodes}" 
            editable="true" 
            selection="#{nodeController.selectedNode}" 
            selectionMode="single" 
            paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"> 

          <p:column headerText="ID"> 
           <h:outputText value="#{node.nodeId}"/> 
          </p:column> 
          <p:column headerText="Nom"> 
           <h:outputText value="#{node.modeName}"/> 
          </p:column> 
          <p:column headerText="Description"> 
           <h:outputText value="#{node.nodeDescription}"/> 
          </p:column>     
          <p:column filterBy="#{node.typeNodeId}" filterMatchMode="exact" headerText="Type"> 
           <f:facet name="filter"> 
            <p:selectOneMenu onchange="PF('nodeTable').filter()"> 
             <f:selectItem itemLabel="filtre" itemValue="#{null}" noSelectionOption="true"/> 
             <f:selectItems value="#{nodeController.nodeTypes}"/> 
            </p:selectOneMenu> 
           </f:facet> 
           <h:outputText value="#{node.typeNodeId}"/> 
          </p:column> 
          <p:column headerText="IPv4"> 
           <h:outputText value="#{node.ipv4}"/> 
          </p:column> 
          <p:column headerText="IPv6"> 
           <h:outputText value="#{node.ipv6}"/> 
          </p:column> 
          <p:column headerText="powwo agent"> 
           <h:selectBooleanCheckbox value="#{node.agentInstalled}"/> 
          </p:column> 
          <p:column headerText="Network status" style="text-align:center"> 
           <p:graphicImage rendered="#{node.isconnected}" name="images/ConnectionStatus25.png" library="omega-layout" width="20"/> 
           <p:graphicImage rendered="#{!node.isconnected}" name="images/Siren-25.png" library="omega-layout" width="20"/> 
          </p:column> 
          <p:column> 
           <p:rowEditor/> 
          </p:column> 

         </p:dataTable> 
         <p:commandButton value="effacer" 
             update="msg" 
             actionListener="#{nodeController.deleteSelectedNode()}"             
             style="width:auto;margin-bottom:10px;margin-top: 10px"/> 
        </h:form> 
       </div> 

      </p:outputPanel> 

你已經滿足這一問題與渲染的確定年代的?任何想法如何解決它?

+0

_「你是否已經遇到了這個問題的datable?」_沒有永遠不會 – Kukeltje

回答

2

實際上,您的標題和第一句不正確。這不是數據表中的錯誤,而是代碼中的一個「錯誤」。在這種情況下,您不應該在p:outputPanel上使用autoupdate="true"。它更新其內部發生的每個ajax更新的所有內容,包括過濾期間的ajax更新。後者更新數據表,這意味着兩個衝突的更新。題外話題:如果您創建了Minimal, Complete, and Verifiable example,那麼在刪除代碼的過程中您會發現這一點。

如果在數據表上的過濾器/頁面/排序/ ...事件之一上有ajax偵聽器,並且面板上的其他事件需要autoUpdate="true",則可以還可以通過在特定事件中添加ignoreAutoUpdate="true"來防止這些特定事件發生autoUpdate。所以例如

<p:ajax event="filter" ignoreAutoUpdate="true" ... />