rich:datatable rowspan问题 [英] rich:datatable rowspan issue

查看:159
本文介绍了rich:datatable rowspan问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用以下功能创建一个富:dataTable(甚至是扩展名):

I need to create a rich:dataTable (or even extended) with the following features:

我有一个类公司有一个Product对象的集合。我想显示下表:

I have a class Company having a collection of Product objects. I want to show the following table:

我仍然没有弄清楚如何使用子表(在所有示例中,我发现subTable与主表具有完全相同的列)。据推测,我需要在前两列中使用rowpans,但我仍然没有找到方法。

I still have not figured out how to do this with a subtable (in all the examples I found the subTable has the exact same columns as the master table). Presumably, I need to play with rowspans in the first two columns, but I still have not found the way.

有人可以为此提供伪代码吗?

Could someone provide a pseudo-code for this?

干杯!

更新1:
我尝试设置 rowspan 作为列表或产品的大小,然后:

UPDATE 1: I tried set the rowspan of the columns in the left as the size of the list or products, and then :


  • 如果产品是空的(公司还没有产品),我打印两列。我有条件地通过将呈现的属性设置为#{myFuncs:sizeOf(company.products)}

  • 如果产品是> = 1然后我用 迭代它们,并在该循环内插入两列(一个用于产品名称,一个用于描述),并且对于每个产品名称列,除了第一个,我设置 breakBefore 属性为#{!myFunc:firstProduct(company.products,product)} ,除第一个产品名称外,所有产品名称的结果均为true。

  • if the products is empty (no products for the company yet), I print two columns. I do this conditionally by setting their rendered attribute to #{myFuncs:sizeOf(company.products)}
  • If the products are >= 1 then I iterate over them with and inside that loop I insert two columns (one for product name and one for description), and for each product name column except the first one I set the breakBefore attribute to #{ !myFunc:firstProduct(company.products, product)}, which evaluates to true for all product names except the first one.

不幸的是,这对我不起作用,因为 a4j:repeat 中的列根本没有出现 - 不是因为呈现标记。循环是正确的,因为如果我打印标准文本,它会出现。

Unfortunately, this did not work for me, because the columns inside the a4j:repeat do not appear at all - not because of the rendered tag. The loop is correct because if I print standard text else, it appears.

有没有办法实现rowpan,或者我是否在墙上敲我的头?

Is there a way to achieve rowspan, or am I banging my head on the wall?

更新2:
问题可能与此相关文章,表示迭代组件之间的差异,例如< a4j:repeat> 和标签< C:的forEach> 即可。第一个在渲染时发生,而第二个在渲染时运行,当JSF组件放在页面的组件树上时。

UPDATE 2: The issue is probably related to this article, indicating the differences between iteration components such as < a4j:repeat> and the tag < c:forEach>. The first takes place at rendering time, while the second one operates earlier, when JSF components are placed onto the component tree of the page.

我试图获得富人: a4j之外的列:重复并且它们被渲染(当然,不是预期的,但它们确实如此)。

I tried to get the rich:columns outside the a4j:repeat and they get rendered (of course, not as expected, but they do).

推荐答案

你可以没有那些复杂的forEachs就可以做到这一点。你只需要利用subTable和rowKeyVar。

You can do this without those complex forEachs. You just need to take advantage of subTable and the rowKeyVar.

例如:

<rich:dataTable
    value="#{backingBean.companyList}"
    rows="100"
    var="company">
    <f:facet name="header">
        <rich:columnGroup>
            <rich:column>Company Name</rich:column>
            <rich:column>Company Email</rich:column>
            <rich:column>Product Name</rich:column>
            <rich:column>Product Email</rich:column>
        </rich:columnGroup>
    </f:facet>
    <rich:subTable value="#{company.products}" var="product" rowKeyVar="rowKey">
        <rich:column rowspan="#{company.products.size()}" rendered="#{rowKey eq 0}">
            #{company.name}
        </rich:column>
        <rich:column rowspan="#{company.products.size()}" rendered="#{rowKey eq 0}">
            #{company.email}
        </rich:column>
        <rich:column>
            #{product.name}
        </rich:column>
        <rich:column>
            #{product.email}
        </rich:column>
    </rich:subTable>
</rich:dataTable>

完美呈现给我。请注意,我使用的是具有Jboss Extended EL的Seam,它允许我在集合上调用size()。如果您不使用它,您可以使用prs:collectionSize()或fn:length()作为替代。

Renders perfectly for me. Note that I'm using Seam which has Jboss Extended EL that allows me to call size() on the collection. If you aren't using this you can use that prs:collectionSize() or fn:length() as a substitute.

这也适用于Richfaces数据循环器。

This also works nicely with the Richfaces datascroller.

希望这会有所帮助。

D。

这篇关于rich:datatable rowspan问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆