简体   繁体   English

具有动态列和过滤功能的primefaces dataTable不再更新

[英]primefaces dataTable with dynamic columns and filtering does no more update

I have a primefaces data table with dynamic columns and filtering for each column which shows search results. 我有一个primefaces数据表,其中包含动态列,并对显示搜索结果的每一列进行过滤。 The data table is updated after each search execution with update="@form" . 每次搜索执行后,都使用update="@form"数据表。 Unfortunately the data table is no more updated after the user has done a filtering for a column. 不幸的是,在用户对列进行过滤之后,数据表不再更新。 The data table does not show new search results after an executed search until the user changes the view and returns to the data table (the search results are stored in the session), this builds the data table new from scratch. 数据表在执行搜索后不会显示新的搜索结果,直到用户更改视图并返回到数据表(搜索结果存储在会话中)之后,这才从头开始构建新的数据表。

This is the data table xhtml: 这是数据表xhtml:

<p:dataTable id="searchResultTableId" scrollable="true" value="#{curSearch.getSearchResults()}" scrollHeight="300" var="curSearchResult"
    sortMode="multiple" rowKey="#{curSearchResult.hashCode()}" draggableColumns="true" resizableColumns="true" styleClass="hitlistDataTable"
    paginator="true" rows="#{curSearch.hitlistRowsPerPage}" rowIndexVar="rowIndex"
    paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
    rowsPerPageTemplate="#{curSearch.rowsPerPageTemplate}" paginatorPosition="bottom" tableStyleClass="searchResultTable"
    selection="#{curSearch.selectedSearchResults}" widgetVar="hitlistTableVar">

    <p:ajax event="colReorder" update="searchResultTableId :editPropertyFormId:editPropertyDialogId" oncomplete="hitlistTableResized();" />

    <p:ajax event="rowSelect" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="rowUnselect" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="toggleSelect" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="rowSelectCheckbox"
        update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="rowUnselectCheckbox"
        update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId" />
    <p:ajax event="contextMenu" update="@(.resultlistActionGrid) :searchInstancesFormId:listResultTabViewId:searchResultTableContextMenuId"
        oncomplete="PF('searchResultTableContextMenuVar').show(currentEvent);" />

    <!-- double click listener -->
    <p:ajax event="rowDblselect"
        listener="#{editPropertyBL.initForEdit(curSearch.selectedSearchResults.get(0), curSearch.getDataViewDefinition())}"
        oncomplete="PF('editPropertyDialogVar').show();" update=":editPropertyFormId @(.resultlistActionGrid)" />

    <p:column style="width: 16px;">
        <p:rowToggler />
    </p:column>
    <p:column selectionMode="multiple" style="width: 16px; text-align:center; padding-right: 12px;" />

    <p:columns value="#{curSearch.determinePrimaryPropertyNames()}" var="curPrimaryPropName"
        sortBy="#{curSearchResult[curPrimaryPropName].getValue()}" filterBy="#{curSearchResult[curPrimaryPropName].getValue()}"
        filterMatchMode="contains">

        <f:facet name="header">
            <h:outputText value="#{displayNameResolver.resolveDisplayNameOfHitlistProperty(curPrimaryPropName, curSearch)}" />
        </f:facet>

        <ui:param name="curValue" value="#{hitlistBL.generatePropertyValue(curSearchResult, curPrimaryPropName)}" />
        <ui:param name="isDocumentTitle" value="#{hitlistBL.isDocumentTitle(curPrimaryPropName)}" />
        <ui:param name="isChoice" value="#{hitlistBL.isChoice(curPrimaryPropName, curSearch)}" />

        <!-- doc title -->
        <h:panelGroup rendered="#{curSearchResult.isChanged() and (isDocumentTitle)}" style="padding-right: 4px;">
            <i class="fa fa-refresh" />
        </h:panelGroup>
        <!-- <p:commandLink action="#{contentBL.showContentExtern(curSearch.getViewId(), curSearchResult)}" value="#{curValue}" ajax="false"
            rendered="#{(curSearchResult.isOfDataType('STRING', curPrimaryPropName)) and (isDocumentTitle) and (not isChoice)}" target="_blank" /> -->

        <!-- document title -->
        <h:outputText value="#{curValue}" title="#{curSearchResult.getRepresentationsAsString()}"
            rendered="#{(curSearchResult.isOfDataType('STRING', curPrimaryPropName)) and (isDocumentTitle) and (not isChoice)}" />

        <!-- data type STRING -->
        <h:outputText value="#{curValue}"
            rendered="#{curSearchResult.isOfDataType('STRING', curPrimaryPropName) and (not isDocumentTitle) and (not isChoice)}" />

        <!-- data type UUID -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('UUID', curPrimaryPropName) and (not isChoice)}" />

        <!-- data type INTEGER32 -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('INTEGER32', curPrimaryPropName) and (not isChoice)}">
            <f:convertNumber integerOnly="true" groupingUsed="false" />
        </h:outputText>

        <!-- data type DOUBLE -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('DOUBLE', curPrimaryPropName) and (not isChoice)}">
            <f:convertNumber groupingUsed="false" />
        </h:outputText>

        <!-- data type DATETIME -->
        <h:outputText value="#{curValue}" rendered="#{curSearchResult.isOfDataType('DATETIME', curPrimaryPropName) and (not isChoice)}">
            <f:convertDateTime type="both" dateStyle="short" timeStyle="short" timeZone="#{settingsBL.getTimeZoneIdSet()}"
                pattern="#{settingsBL.dateTimePattern}" />
        </h:outputText>

        <!-- CHOICE -->
        <h:outputText value="#{hitlistBL.determineChoiceUiValue(curSearch.getViewId(), curSearchResult, curPrimaryPropName)}"
            rendered="#{(not isDocumentTitle) and (isChoice)}" />

    </p:columns>

    <p:rowExpansion>
        <h:panelGrid id="addPropsOuterGridId" cellpadding="0" cellspacing="0" columns="2" columnClasses="expRowImage, expRowProps"
            styleClass="resultListRowExpansionGrid">
            <h:panelGroup style="height: 200px;">
                <p:graphicImage value="#{imageCacheBean.image}" height="200" cache="false"
                    rendered="#{curSearchResult.isContentRepresentationWithNameExisting('thumbnails')}">
                    <f:param name="searchTabId" value="#{curSearch.getTabId().toString()}" />
                    <f:param name="searchViewId" value="#{searchViewBL.getSelectedSearchViewId().toString()}" />
                    <f:param name="searchPid" value="#{curSearchResult.getPid().getPidString()}" />
                </p:graphicImage>
            </h:panelGroup>

            <p:dataGrid id="addPropDataGridId" var="curSecondaryPropName" value="#{curSearch.determineSecondaryPropertyNames()}" columns="1"
                layout="grid" styleClass="hitlistAdditionalPropDataGrid" emptyMessage="">

                <ui:param name="isChoice" value="#{hitlistBL.isChoice(curSecondaryPropName, curSearch)}" />

                <h:panelGrid id="addPropsInnerGridId" columns="2" cellpadding="0" cellspacing="0"
                    columnClasses="hitlistAddPropLabel, hitlistAddPropValue" style="width: 100%;">
                    <h:outputText value="#{displayNameResolver.resolveDisplayNameOfHitlistProperty(curSecondaryPropName, curSearch)}: " />

                    <ui:param name="curSecondaryValue" value="#{hitlistBL.generatePropertyValue(curSearchResult, curSecondaryPropName)}" />

                    <!-- data type STRING -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('STRING', curSecondaryPropName) and (not isChoice)}" />

                    <!-- data type UUID -->
                    <h:outputText value="#{curSecondaryValue}" rendered="#{curSearchResult.isOfDataType('UUID', curSecondaryPropName) and (not isChoice)}" />

                    <!-- data type INTEGER32 -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('INTEGER32', curSecondaryPropName) and (not isChoice)}">
                        <f:convertNumber integerOnly="true" groupingUsed="false" />
                    </h:outputText>

                    <!-- data type DOUBLE -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('DOUBLE', curSecondaryPropName) and (not isChoice)}">
                        <f:convertNumber groupingUsed="false" />
                    </h:outputText>

                    <!-- data type DATETIME -->
                    <h:outputText value="#{curSecondaryValue}"
                        rendered="#{curSearchResult.isOfDataType('DATETIME', curSecondaryPropName) and (not isChoice)}">
                        <f:convertDateTime type="both" dateStyle="short" timeStyle="short" timeZone="#{settingsBL.getTimeZoneIdSet()}"
                            pattern="#{settingsBL.dateTimePattern}" />
                    </h:outputText>

                    <!-- CHOICE -->
                    <h:outputText value="#{hitlistBL.determineChoiceUiValue(curSearch.getViewId(), curSearchResult, curSecondaryPropName)}"
                        rendered="#{isChoice}" />

                </h:panelGrid>
            </p:dataGrid>
        </h:panelGrid>
    </p:rowExpansion>

</p:dataTable>

You need to clear the filtering while doing search on button. 在按钮上进行搜索时,您需要清除过滤条件。 Use widgetVar="hitlistTableVar" for your datatable and then 为数据表使用widgetVar="hitlistTableVar" ,然后

on your command button clear the filter. 在命令按钮上,清除过滤器。

 oncomplete="hitlistTableVar.clearFilters();"

Hope it should solve your problem. 希望它能解决您的问题。

` `

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

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