简体   繁体   English

汇总行 JSF 数据表

[英]Summary row JSF DataTable

I have to put in summary many columns summarizing the results, and in jsf datatable i cant do it, someone know how can i do it?我必须总结许多列来总结结果,在 jsf 数据表中我做不到,有人知道我该怎么做吗? without use primefaces不使用 primefaces

im got this result我得到了这个结果

<h:dataTable id="tableResult" value="#{managedBean.dataModel}"
                                    var="obj" rows="15" layout="block" styleClass="table">
    <h:column>
            <f:facet name="header">Total abandonada</f:facet>
            <h:outputText value="#{obj.totalAbandon}">
            </h:outputText>
        </h:column>
        <h:column>
            <f:facet name="header">Total</f:facet>
            <h:outputText value="#{obj.total}" />

        </h:column>
        <h:column>
            <f:facet name="header"> Atendidas %</f:facet>
            <h:outputText value="#{obj.percentualAnswered}%" />
        </h:column>
        <h:column>
            <f:facet name="header">Abandonos %</f:facet>
            <h:outputText value="#{obj.percentualAbandon}%" />
        </h:column>
        <f:facet name="footer">#{obj.suumary}
        </f:facet>
</h:dataTable>

to got this result im using得到这个结果我正在使用

<f:facet name="footer">Total : 2</f:facet>

but i want this result但我想要这个结果

<tr>
<td>Total : 2</td> 
<td>Total answered : 1</td>
<td>Total abandon : 1</td>
</tr>
</tfoot>

i have been tried use 2 footer facet and doesnt work我已尝试使用 2 页脚刻面但不起作用

A plain JSF h:datatable does not have the notion of something like a summary per group of rows built in. So if this is what you want, you need to either switch to eg PrimeFaces or add the summary row to your model in the right place and be creative with the CSS for the rows and the content.一个普通的 JSF h:datatable没有类似于内置的每组行的摘要的概念。因此,如果这是您想要的,您需要切换到例如 PrimeFaces 或将摘要行添加到您的 Z20F35E630DAF394DC4F 右侧使用 CSS 放置行和内容并发挥创意。

If you want a footer for the full datable, the footer facet is the right thing (a summary of the datatable).如果您想要完整数据表的页脚,页脚方面是正确的(数据表的摘要)。 But in this footer you cannot use the variable you assigned in the var attribute, in your case obj Think of it, which obj should be used?但是在这个footer中你不能使用你在var属性中赋值的变量,在你的情况下obj想想,应该使用哪个obj呢? The first?首先? Second?第二? Last?最后的? All (each)?所有(每个)? So add a field to the managedBean that contains the 'summary' and display that.因此,向包含“摘要”的managedBean添加一个字段并显示它。

<f:facet name="footer">#{manageBean.summary}</f:facet>

If summary is a list, you can iterate over it like mentioned in Iterate over nested List property inside h:datatable如果summary是一个列表,您可以像迭代 h:datatable 中的嵌套列表属性中提到的那样对其进行迭代

The html you'll end up is你最终会得到的 html 是

<tfoot>
   <tr> 
       <td>
          .... your content of the nested list
       </td>
   </tr>
</tfoot>

This contnt can be either a table, list, div's or whatever you want.此内容可以是表格、列表、div 或任何您想要的。

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

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