gpt4 book ai didi

java - PrimeFaces 3.0 -

headers do not line up with using scrollable ="true"

转载 作者:太空狗 更新时间:2023-10-29 22:58:30 25 4
gpt4 key购买 nike

我有一个使用 PrimeFaces 3.0 组件的 JSF 2 网络应用程序。在一页上,我使用 <p:dataTable>复合组件内的组件以显示对象表。在我尝试使用 scrollable="true" 之前,我已经成功使用了这个组件选项。现在表格列标题不与列内容对齐。我曾尝试使用 IE 7(这是我的客户端环境的目标浏览器)和 Firefox 4.0.1 进行比较。两者都存在问题,但在 IE 7 中更为明显。

IE 7 截图:

IE 7 screenshot

Firefox 4.0.1 截图:

Firefox 4.0.1 screenshot

这是我的一些 Facelet 页面代码:

<p:dataTable
id="vesselsDataTable"
value="#{cc.attrs.vesselAdapterList}"
var="currentRow"
selection="#{editVesselBean.selectedRow}"
selectionMode="single"
scrollable="true"
height="500">
<p:column
id="imoColumn"
style="width:45px"
sortBy="#{currentRow.imo}">
<f:facet name="header">
<h:outputText value="IMO" />
</f:facet>
<div class="#{currentRow.imoStyleClass}">
<h:outputText value="#{currentRow.imo}"
</div>
</p:column>
<p:column
id="notesIndicatorColumn"
style="width:35px"
sortBy="#{currentRow.hasNotes}">
<f:facet name="header">
<h:outputText value="#{bundle.labelNotes}" />
</f:facet>
<h:outputText
styleClass="noteIndicator"
id="vesselNotesIndicator"
value="#{bundle.stringNoteIndicatorText}"
title="#{currentRow.notesAsTooltipText}"
rendered="#{currentRow.hasNotes}"
</p:column>
<ui:remove>other column definitions omitted for brevity...</ui:remove>
<p:dataTable>

我的每个列都有一个以像素为单位定义的固定宽度的样式,并且 dataTable 本身有 height属性集。这似乎与 Showcase 演示和 2.2 手册 PDF 中显示的相同。

引用手册:

Scrolling is a way to display data with fixed headers, in order to enable simple scrolling set scrollable options to true, define a fixed height in pixels and set a fixed width to each column.

谁能告诉我我做错了什么?

我正在使用当前的 PrimeFaces 3.0-M2-SNAPSHOT 和当前的 Mojarra 2.1 JSF RI。

更新

我已经转到 PrimeFaces 3.0-M2(不是快照)版本,但问题仍然存在。根据 Maple 和 BalusC 的建议,我(暂时)删除了列排序并尝试了不同的文档类型。我最终选择了 XHTML 1.0 Strict 文档类型。它没有显示 IE 7 中的任何改进,但确实显示了 Firefox 4 中的一些改进。

IE 7 与 XHTML 1.0 Strict

IE 7 with XHTML 1.0 Strict

Firefox 4 与 XHTML 1.0 Strict

Firefox 4 with XHTML 1.0 Strict

<p:dataTable><p:panel>里面在<p:layout>里面.这可能相关吗?

最佳答案

这显然是一个 CSS/JS 问题。具有固定标题的可滚动表格在纯 HTML 中是不可能的(如果 tbody { overflow: scroll; }所有浏览器支持...)。 A lot已经发明了多种不同的 CSS/JS 解决方案(黑客)来实现这一目标。我不了解 PF 3 源代码,也不知道它使用的是哪种 hack。但这肯定需要是 reported给 PF 们。您唯一可以做的就是检查您是否正在使用 the proper HTML doctype (阅读:strict 文档类型)这样至少 MSIE 不会在 quirks mode 中运行.

例如HTML5

<!DOCTYPE html>

或 XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<f:view contentType="text/html">

或 XHTML 1.0 严格

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<f:view contentType="text/html">

或者可能是 XHTML 1.0 Transitional

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view contentType="text/html">

关于java - PrimeFaces 3.0 - <p :dataTable> headers do not line up with using scrollable ="true",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6536987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com