提取Tree内置过滤器以分隔输入

时间:2018-06-14 10:12:39

标签: jsf primefaces

我目前正在使用Primefaces开发应用程序,最近开始使用Tree组件。它完全提供了我需要的功能,但在对话框中使用它时遇到了一些问题。当有许多记录时,我必须用<p:outputPanel>围绕这棵树以便滚动。一切都很好,直到我添加过滤到该树组件。由于包围的面板,此过滤器输入文本显示在树的正上方,在此面板内部,当我向下滚动时,此过滤器输入保留在顶部上方。

是否有可能在整个面板上方手动添加过滤器输入并将其连接到树,例如在PrimeFaces的DataTable组件中完成?试过这种方式却没有用。下面是我的对话框的.xhtml。任何帮助将不胜感激。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://xmlns.jcp.org/jsf/core">
    <p:dialog id="manageKnownDeviceDlg" header="#{msg['ip.usb.manageKnownDlg.Title']}" height="700"
              showEffect="explode" resizable="true" modal="true" appendTo="@(body)"
              width="700" widgetVar="manageKnownDeviceDlg" style="text-align: right;">
        <h:form id="manageKnownDialogForm" >
            <p:outputPanel style="width: 100%; max-height: 600px; min-height: 600px;height: 88%;overflow: auto;display: block; border: solid 1px;">
                <p:tree id="manageKnownDevicesTree" var="knownDevice" value="#{baseModel.usbDeviceDictTreeRoot}"
                        widgetVar="usbDeviceDictTree"
                        selectionMode="checkbox" selection="#{baseModel.usbDeviceDictSelected}"
                        filterBy="#{knownDevice}" filterMatchMode="contains" emptyMessage="#{msg['global.noData']}"
                        style="text-align: left; width: 98%;">
                    <p:treeNode>
                        <h:outputText value="#{knownDevice.toString()}"/>
                    </p:treeNode>
                </p:tree>
            </p:outputPanel>
            <br/>
            <h:panelGrid columns="1" style="position: absolute; right: 5px;">
                <h:panelGrid columns="5" style="margin-top: 10px;">
                    <p:commandButton value="#{msg['ip.usb.manageKnownDlg.Disable']}" update="manageKnownDevicesTree"
                                     actionListener="#{knownDevicesDlgController.unselectKnownDeviceClasses}" styleClass="vs-button"
                                     process="manageKnownDeviceDlg"/>
                    <p:commandButton value="#{msg['ip.usb.manageKnownDlg.YesToAll']}" update="manageKnownDevicesTree"
                                     actionListener="#{knownDevicesDlgController.selectAllDevices}" styleClass="vs-button"
                                     process="manageKnownDeviceDlg"/>
                    <p:commandButton value="#{msg['ip.usb.manageKnownDlg.NoToAll']}" update="manageKnownDevicesTree"
                                     actionListener="#{knownDevicesDlgController.unselectAllDevices}" styleClass="vs-button"
                                     process="manageKnownDeviceDlg"/>
                    <p:commandButton value="#{msg['global.ok']}" update="usbForm:usbDeviceTable,manageKnownDialogForm"
                                     onclick="PF('manageKnownDeviceDlg').hide();" process="manageKnownDeviceDlg" styleClass="vs-button"
                                     actionListener="#{knownDevicesDlgController.addKnownDevice}" style="text-align: right"/>
                    <p:commandButton value="#{msg['global.cancel']}" update="manageKnownDeviceDlg" styleClass="vs-button"
                                     onclick="PF('manageKnownDeviceDlg').hide();"/>
                </h:panelGrid>
            </h:panelGrid>
        </h:form>
    </p:dialog>
</ui:composition>

1 个答案:

答案 0 :(得分:1)

在ui-tree-container上设置max-height解决了这个问题。在展示中使用它

.ui-tree-container {
    max-height: 70px;
}

结果

enter image description here

您可能希望向树中添加一个显式类,并在选择器中使用它,因此它不适用于所有树。