开发者

Group visibility of rich:columns inside rich:datatable

I have a set of columns inside a rich:datatable, those columns are visible based on some preprocessed conditions. An example of what I want to do is this:

<rich:datatable value="tableList" var="list">

    <h:panelGroup rendered="#{condition}">
        <rich:column>
            Component
        <rich:column>

        <rich:column>
            Component
        &开发者_开发知识库lt;rich:column>
    </h:panelGroup>

    <h:panelGroup rendered="#{not condition}">
        <rich:column>
            Component
        </rich:column>
    </h:panelGroup>

</rich:datatable>

The problem here is that the panelGroup tag never gets rendered inside the rich:datatable, even when I remove the "rendered" condition. I tried with an a4j:outputPanel and a few others but none worked.

I could remove the panel and put the condition in each column but that would be the last thing I would do.

Why is not working? Regards.


In fact, I am pretty sure that the <rich:dataTable> will ignore any direct children that are not a UIColumn or Column object (I just had a look on org.richfaces.component.ColumnsIterator, used by UIDataTable).

In others words, your <h:panelGroup> will simply be ignored by the <rich:dataTable>, not matter when the rendered attribute value is.

To solve your problem, I see three solutions:

  1. Put a rendered attribute on each <rich:column>;
  2. Use the <rich:columnGroup> component;
  3. Define two <rich:dataTable>, one display when #{condition} is evaluated to true, the other one when it is false.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜