简体   繁体   English

p:ajax更新后数据表显示错误

[英]p:datatable displayed wrongly after ajax update

I have problem with a primefaces datable, I have a filter on a column and before to filter the result my datatable is displayed properly like this: 我有一个primefaces datable问题,我在列上有一个过滤器,在过滤结果之前,我的数据表正确显示如下:

良好的展示

When I choose a filter, the combobox of the filter is properly poulated: 当我选择一个过滤器时,该过滤器的组合框已正确填充:

显示过滤器列表

A soon I choose the item for the filter, the results are properly filtered but I have a display of the datatable like this: 很快我为过滤器选择了项目,结果得到了正确的过滤,但是数据表显示如下:

显示错误

I just see the results who should be display in a datatable but the table is gone. 我只看到应该在数据表中显示的结果,但该表已消失。

The code seems good and I don't see where is the problem: 该代码似乎很好,我看不出问题出在哪里:

<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>

Did you already meet this issue with the rendered of a datable? 使用datable的渲染是否已经解决了这个问题? Any idea how to fix it? 知道如何解决吗?

Effectively, your title and first sentence are not correct. 实际上,您的标题和第一句话是不正确的。 It is not a bug in the datatable but a 'bug' in your code. 这不是数据表中的错误,而是代码中的“错误”。 You should not use autoupdate="true" on the p:outputPanel in this case. 在这种情况下,不应在p:outputPanel上使用autoupdate="true" It updates all its content on each ajax update that happens inside it, including an ajax update during filtering. 它会在其内部发生的每个ajax更新中更新其所有内容,包括过滤期间的ajax更新。 This latter also updates the datatable which means two conflicting updates. 后者更新了数据表,这意味着两个冲突的更新。 Off-topic: If you'd created a Minimal, Complete, and Verifiable example , you'd have found this out during removal of code. 离题:如果您创建了一个最小,完整和可验证的示例 ,则在删除代码的过程中会发现这一点。

If you have this problem when you have an ajax listener on one of the filter/page/sort/... events on the datatable and you need the autoUpdate="true" on the panel for other events in the wrapping panel, you could also prevent the autoUpdate to happen for these specific events by adding a ignoreAutoUpdate="true" to the specific events. 如果在数据表的filter / page / sort / ...事件之一上具有ajax侦听器时遇到此问题,并且需要包装面板上的其他事件在面板上使用autoUpdate="true" ,则可以通过向特定事件添加ignoreAutoUpdate="true" ,还可以防止针对这些特定事件进行自动ignoreAutoUpdate="true" So eg 所以例如

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

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

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