Displaytag footer average
Im using displaytag to create reports. In the footer of the report i would like to show the average sum of a couple of my columns. Average sum of "pris" and "dekningsprosent".
Is this possible with displaytag? I have seen there is a method for counting totals, but i cant find for average.
Hope you guys can help! Here is my code so far:
<display:table name="rapportList" class="tab开发者_运维百科le" requestURI="" id="rapportList" export="true" pagesize="25">
<display:column property="leilighetId" sortable="true" titleKey="report.header.leilighetId"/>
<display:column property="pris" sortable="true" titleKey="report.header.price" format="{0,number,currency}"/>
<display:column property="dekningProsent" sortable="true" titleKey="report.header.coverage" format="{0,number,percent}"/>
<display:footer>
//What goes in here to get the average?
</display:footer>
</display>
Thanks in advance!
Try this:
in your displayTag
declarations, you put the varTotals
properties:
<display:table name="rapportList" class="table" requestURI="" id="rapportList" export="true" pagesize="25" varTotals="myTotalValue">
and after that you must in each column you want to sum the property total="true"
:
<display:column property="pris" sortable="true" titleKey="report.header.price" format="{0,number,currency}"/>
the last step is make your footer receive the sum calculations, like:
<display:footer>
<td>${myTotalValue.column2}</td>
</display:footer>
Don't forget that the number of the columns in this case starts with one, and not zero like the arrays patterns
精彩评论