Subdataset - total rows in the List

大城市里の小女人 提交于 2019-12-25 18:42:17

问题


I have created a subdataset in my main report and using that to create a list. The list displays all the rows from my dataset, but is there a way to place a total number of rows count in the list component.

With the $V{REPORT_COUNT} variable, i can get the total count but its repeated multiple times (as the number of rows in the sub dataset )


回答1:


Create A second List set it to use the same dataset and put only the $V{REPORT_COUNT} in it. Set the position type to float

Second option is to use the Table in place of the List as it has the banding to allow for a header or footer of your dataset




回答2:


As noted in the answer by user jmurray here: http://community.jaspersoft.com/questions/514827/row-count

In your subDataSet, create a variable:

<variable name="ROW_COUNTER" class="java.lang.Integer" incrementType="Report" calculation="Count">
    <variableExpression><![CDATA[new java.lang.Integer(1)]]></variableExpression>
    <initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
</variable>

Then somewhat like what Mike Noland has in his answer, create a list that points to the same subDataSet as the original list with a textField:

<textField>
    <reportElement isPrintRepeatedValues="false" x="0" y="0" width="100" height="11"/>
    <textFieldExpression><![CDATA[new java.lang.Integer($V{ROW_COUNTER}.intValue()+1)]]></textFieldExpression>
</textField>

This creates a zero based counter that holds the total count of items. Then by telling the report not to print repeats, you end up with a single item that represents the total number of items in your subDataSet



来源:https://stackoverflow.com/questions/17495038/subdataset-total-rows-in-the-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!