子数据集-列表中的总行 [英] Subdataset - total rows in the List
问题描述
我已经在主报表中创建了一个子数据集,并使用该子表创建了一个列表.该列表显示了我的数据集中的所有行,但是有一种方法可以将总行数放入列表组件中.
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.
使用$V{REPORT_COUNT}
变量,我可以获取总计数,但是可以重复多次(作为子数据集中的行数)
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 )
推荐答案
用户jmurray在此处的回答中指出: http://community.jaspersoft.com/questions/514827/row-count
As noted in the answer by user jmurray here: http://community.jaspersoft.com/questions/514827/row-count
在您的subDataSet
中,创建一个变量:
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>
然后像Mike Noland在回答中一样,创建一个列表,并使用textField
指向与原始列表相同的subDataSet
:
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
这篇关于子数据集-列表中的总行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!