【问题标题】:Primefaces p:panel width issue inside in p:layoutPrimefaces p:p:layout中的面板宽度问题
【发布时间】:2013-08-01 06:31:12
【问题描述】:

Primefaces 3.5

当我在p:panel 中设置p:dataTable 时,面板无法显示兼容宽度。 问题是table width 大于panel width,如下图所示。

如果我删除p:layout,就可以了。

我想得到比table width 大的panel with。用jQuery能解决吗?

panel.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
    <h:head>
    </h:head>   
    <h:body>
        <p:layout fullPage="true">
            <p:layoutUnit position="west" size="260">
                left
            </p:layoutUnit>
            <p:layoutUnit position="north" size="50">
                header
            </p:layoutUnit>
            <p:layoutUnit position="center" resizable="true">
                <h:form enctype="multipart/form-data">
                            <p:panel header="Vehicle Information" id="vehicleInfoWizardPanel">  
                                <p:dataTable id="vehicleTable">
                                    <p:column headerText="Sr. No">
                                    </p:column>
                                    <p:column headerText="Registration No">
                                    </p:column>
                                    <p:column headerText="Model">
                                    </p:column>
                                    <p:column headerText="Engine No">
                                    </p:column>
                                    <p:column headerText="Chassis No">
                                    </p:column>
                                    <p:column headerText="Cubic Capacity">
                                    </p:column>
                                    <p:column headerText="Seating">
                                    </p:column>
                                    <p:column headerText="Weight (Ton)">
                                    </p:column>
                                    <p:column headerText="Sum Insured">
                                    </p:column>
                                    <p:column headerText="Product Type">
                                    </p:column>
                                    <p:column headerText="Add On">
                                    </p:column>
                                    <p:column headerText="Period (Month)">
                                    </p:column>
                                    <p:column headerText="Manufacture">
                                    </p:column>
                                    <p:column headerText="Type Of Body">
                                    </p:column>
                                </p:dataTable>
                            </p:panel>
                </h:form>
             </p:layoutUnit>
            <p:layoutUnit position="east" size="260">
                Right
            </p:layoutUnit>
            <p:layoutUnit position="south" size="40">
                footer
            </p:layoutUnit>
        </p:layout>
    </h:body>
</html>

更新

即使我通过 jquery 获取面板宽度,它总是返回 null

var width = $("#vehicleInfoWizardPanel").width();
alert(width);

但是,我得到了惊人的观点。如果我删除h:form,不使用jquery 一切正常。

【问题讨论】:

  • 为什么不简单地使用p:panelstyle 属性并设置width(例如style = "width: 500px")。根据需要更改大小。
  • @Andy,修复宽度?我想要 100% 的宽度,但它将与 p:layout 内容兼容
  • 这只是一个建议,100% 宽度不起作用?
  • 我喜欢,不行。

标签: jquery jsf jsf-2 primefaces


【解决方案1】:

如果仔细观察,宽度已经是 100%。面板的宽度是相对于其封闭容器的。您需要增加宽度尺寸才能获得所需的结果。你可以通过使用p:panelstyle 属性来做到这一点,就像这样

<p:panel style="width: 200%" header="Vehicle Information"  id="vehicleInfoWizardPanel">  

您还可以覆盖 PrimeFaces CSS 类 .ui-panel。您可能会发现此链接很有用

How to override stylesheets of PrimeFaces?

【讨论】:

  • 哇,没关系。我不需要删除任何标签。谢谢 :) 我刚刚设置了 150%。
猜你喜欢
  • 2014-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-22
  • 2013-05-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多