Primefaces 数据 table 排序和对齐
Primefaces data table sorting and aligning
我想从 Arraylist 动态构建网站页脚。我将 primefaces 用作 UI。
下面的绿色图像是我想要使用 primefaces 的图像,到目前为止我得到的数据 table 如下图(蓝色和白色)。
这是我正在使用的 primefaces 代码。有人可以告诉我如何使用 primefaces 数据 table 或数据列表来构建页脚,如下面的绿色图像。
在 footer2List 我有 "category" 作为 header 喜欢(社交媒体,社区)和 "description" 作为 child 数据。
提前致谢。
<p:dataTable var="fot" value="#{footer2MB.footer2List}" sortBy="#{fot.category}">
<p:columnGroup type="header">
<p:row>
<p:column colspan="2">
<b><h:outputText value="#{fot.category}"/></b>
</p:column>
</p:row>
</p:columnGroup>
<p:column headerText="fotId" colspan="7">
<h:outputLink target="_new#{fot.url}" value="#{request.contextPath}#{fot.url}">
<h:outputText value = "#{fot.description}" />
</h:outputLink>
</p:column>
</p:dataTable>
当你试图(滥用)使用数据table时,这真的感觉就像你在试图把一个圆钉放在一个方孔里。与使用两个嵌套的 ui:repeats
.
相比,您需要像显示的那样格式化它的 css 的数量不成比例地高
你好像是一对一的父子关系table。因此,如果您还没有这样做,请先像“JPA mapping for Parent-Child with same class”中那样对您自己的 JPA 实体进行建模(如果您不使用 jpa,则需要编写一些代码,但这也相当简单直接)
编写 JQL 检索顶级记录:select r from MyRecord r where parent_id is null
.
然后在伪代码中做:
<ui:repeat value="#{myBean.rootRecords}" var="rootRecord">
<h3>#{rootRecord.title}</h3>
<ul>
<ui:repeat value="#{rootRecord.children}" var="child">
<li>#{child.title}</li>
</ui:repeat>
</ul>
</ui:repeat>
这就是这里所做的事情:Displaying the values of a nested array list in JSF data table
您可以查看的一个优化是 JPA 中子项的惰性加载或急切加载。另一个是使用 p:cache
...
一切都简单明了,没有数据的麻烦table。
(题外话:我几乎 100% 确定您已经花了更多时间尝试(滥用)使用数据table 并创建问题并与我讨论,这比如果您花费更多时间直接按照此答案中描述的方式进行操作 ;-))
我想从 Arraylist 动态构建网站页脚。我将 primefaces 用作 UI。
下面的绿色图像是我想要使用 primefaces 的图像,到目前为止我得到的数据 table 如下图(蓝色和白色)。
这是我正在使用的 primefaces 代码。有人可以告诉我如何使用 primefaces 数据 table 或数据列表来构建页脚,如下面的绿色图像。 在 footer2List 我有 "category" 作为 header 喜欢(社交媒体,社区)和 "description" 作为 child 数据。
提前致谢。
<p:dataTable var="fot" value="#{footer2MB.footer2List}" sortBy="#{fot.category}">
<p:columnGroup type="header">
<p:row>
<p:column colspan="2">
<b><h:outputText value="#{fot.category}"/></b>
</p:column>
</p:row>
</p:columnGroup>
<p:column headerText="fotId" colspan="7">
<h:outputLink target="_new#{fot.url}" value="#{request.contextPath}#{fot.url}">
<h:outputText value = "#{fot.description}" />
</h:outputLink>
</p:column>
</p:dataTable>
当你试图(滥用)使用数据table时,这真的感觉就像你在试图把一个圆钉放在一个方孔里。与使用两个嵌套的 ui:repeats
.
你好像是一对一的父子关系table。因此,如果您还没有这样做,请先像“JPA mapping for Parent-Child with same class”中那样对您自己的 JPA 实体进行建模(如果您不使用 jpa,则需要编写一些代码,但这也相当简单直接)
编写 JQL 检索顶级记录:select r from MyRecord r where parent_id is null
.
然后在伪代码中做:
<ui:repeat value="#{myBean.rootRecords}" var="rootRecord">
<h3>#{rootRecord.title}</h3>
<ul>
<ui:repeat value="#{rootRecord.children}" var="child">
<li>#{child.title}</li>
</ui:repeat>
</ul>
</ui:repeat>
这就是这里所做的事情:Displaying the values of a nested array list in JSF data table
您可以查看的一个优化是 JPA 中子项的惰性加载或急切加载。另一个是使用 p:cache
...
一切都简单明了,没有数据的麻烦table。
(题外话:我几乎 100% 确定您已经花了更多时间尝试(滥用)使用数据table 并创建问题并与我讨论,这比如果您花费更多时间直接按照此答案中描述的方式进行操作 ;-))