简体   繁体   English

rich:datatable中的rich:列的组可见性

[英]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. 我在rich:datatable中有一组列,这些列基于某些预处理条件是可见的。 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
        <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. 这里的问题是,即使删除了“ rendered”条件,panelGroup标记也永远不会在rich:datatable内部呈现。 I tried with an a4j:outputPanel and a few others but none worked. 我尝试了a4j:outputPanel和其他几个,但是没有一个起作用。

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 ). 事实上,我敢肯定的是, <rich:dataTable>会忽略任何直接的孩子,是不是UIColumnColumn的对象(我只是在看org.richfaces.component.ColumnsIterator ,通过使用UIDataTable )。

In others words, your <h:panelGroup> will simply be ignored by the <rich:dataTable> , not matter when the rendered attribute value is. 换句话说,您的<h:panelGroup>只会被<rich:dataTable>忽略,无论何时rendered属性值都没有关系。

To solve your problem, I see three solutions: 为了解决您的问题,我看到了三种解决方案:

  1. Put a rendered attribute on each <rich:column> ; 在每个<rich:column>上放置一个rendered属性;
  2. Use the <rich:columnGroup> component; 使用<rich:columnGroup>组件;
  3. Define two <rich:dataTable> , one display when #{condition} is evaluated to true , the other one when it is false . 定义两个<rich:dataTable> ,一个在#{condition}评估为true ,另一个在false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM