Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 调整p:树以使用可用高度_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 调整p:树以使用可用高度

Jsf 2 调整p:树以使用可用高度,jsf-2,primefaces,Jsf 2,Primefaces,我的程序逻辑运行良好,但我不知道如何使关键组件将其大小调整到屏幕的可用高度。例如,我有: <p:layout id="workLayout" style="margin-top: 5px; height: 95%"> <p:layoutUnit position="west" resizable="true"

我的程序逻辑运行良好,但我不知道如何使关键组件将其大小调整到屏幕的可用高度。例如,我有:

            <p:layout id="workLayout" style="margin-top: 5px; height: 95%">

                <p:layoutUnit position="west"
                              resizable="true"
                              minSize="50"
                              size="200">

                    <h:form id="treeForm">
                        <p:tree value="#{workspace.listTree}"
                                var="node"
                                >
                            <p:treeNode>
                                <h:outputText value="#{node.name}" />
                            </p:treeNode>
                        </p:tree>
                    </h:form>

                </p:layoutUnit>

所发生的情况是,它渲染的布局高度约为200px。(CSS高度术语无效)。一旦在树中展开几个节点,就必须开始垂直滚动,同时在p:layout空间下面有大量浪费的空白

有没有关于如何做到这一点的提示

更新:我发现,如果输入这样的绝对高度,我可以接近我想要的效果:

<p:layout id="workLayout" style="margin-top: 5px; height: 6in">


高度值似乎取决于某个外部容器。但是,如果是这种情况,为什么当我更改浏览器窗口的水平大小时,对象能够调整自身大小?我希望它也能响应垂直大小。

在Primefaces3.5中,
p:tree
的CSS以

.ui-tree {
width: 300px;
position: relative;
}
.ui-tree .ui-tree-container {
margin: 0;
padding: 3px;
white-space: nowrap;
overflow: auto;
}
我将使用
style
属性添加CSS属性use-need:
height:100%


在更改代码之前,请使用Chrome或Firefox的开发工具将此样式添加到树中,以确保其正常工作

在使用priming p-tree控件的组件代码中,我使用了一个输入字符串变量,并将其分配给ui树类高度。然后可以将其设置为像素或百分比高度:

import { Component, OnInit, Input, Renderer2, ElementRef} from '@angular/core 

export class PersonnelTreeComponent implements OnInit {

        @Input() height: string;
        treeheight: string = '400px';  

        constructor( private renderer: Renderer2, private elRef: ElementRef) { } 

        ngOnInit() { 
            if (this.height != null) {
                this.treeheight = this.height;
            }  
        }  

        ngAfterViewInit() {
            this.renderer.setStyle(this.elRef.nativeElement.querySelector('.ui-tree'), 'height', this.treeheight );  
        } 
    }
然后,按照通常的方式进行设置:

<personneltree-component  [height]="'100%'"></personneltree-component>


好主意,但似乎没有成功。p:tree的容器是p:layoutUnit,我必须以某种方式调整它,让p:tree扩展以填充该空间。在看到你的答案之前,我不知道有一个用于Angular的PrimeFaces库。它看起来很有趣。我用它来表示“宽度”:“100%”找不到一个简单的方法。谢谢