JasperReports分组可由用户更改 [英] JasperReports grouping changeable by user

查看:101
本文介绍了JasperReports分组可由用户更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这是否可行,但我想弄清楚是否可以使用iReport Designer创建报告,查看报告的用户可以控制分组。

I have no idea if this is possible or not but I'm trying figure out if it is possible to use iReport Designer to create reports where the user viewing the report is able to control the grouping.

例如,我希望用户能够重新排序分组,并更改报告的分组程度(仅在一个字段或多个字段上)。

For example I would like the user to be able to re-order the grouping and also change to which degree the report is grouped (only on one field or on multiple ones).

我不是指SQL分组btw,我的意思是例如按帐户分组然后代理:

I don't mean SQL grouping btw, I mean for example grouping by Account and then Agent:

| Account  |  Agent  | Invoice  | Total |
+----------+---------+----------+-------+
| Account1 |         |          |       |
|          |   Joe   |          |       |
|          |         | Invoice2 | $600  |
|          |         | Invoice1 | $300  |
| Account2 |         |          |       |
|          |   Sam   |          |       |
|          |         | Invoice4 | $120  |
|          |         | Invoice7 | $230  |
|          |   Joe   |          |       |
|          |         | Invoice3 | $200  |
+----------+-- ------+----------+-------+

而我想弄清楚的是,你能用iReport来实现这种分组动态吗?也就是说,用户可能希望首先按代理进行分组,然后按帐户进行分组,而不是每个分组都有一个报告,如果有一种方法可以使用iReport执行此操作,那就太好了。

And what I'm trying to figure out is, can you use iReport to make this grouping dynamic? That is, that the user might want to group by Agent first and Account second and rather than have one report for each grouping it'd be nice if there was a way of doing this with iReport.

推荐答案

是的,应该可以创建这样的报告。但是根据你的具体需要,这可能不太实际(正如Alex K所说)。

Yes, it should be possible to create reports like that. But depending on your exact needs it may not be practical (as Alex K indicated).

如果你只采用你在账户上分组的例子,那么代理或在代理上分组然后帐户,这很简单。有一个让用户指定此选项的参数。它可能是一个下拉列表。然后在报告中你会有这样的字段:

If you take only your example of grouping on Account then Agent or grouping on Agent then account, it would be simple. Have a parameter that let's the user specify this choice. It would probably be a drop down list. Then in the report you would have fields like this:

今天的版本: $ F {Account} $ F {Agent}

动态版本: $ P {AcctFirst}? $ F {Account}:$ F {Agent} $ P {AcctFirst}? $ F {Agent}:$ F {Account}

同样,组定义需要包含新的AcctFirst参数。

Likewise, the group definition would need to include the new AcctFirst param.

但它不会很好地扩展。如果2个字段是不同的数据类型怎么办?如果您想让用户从3或4或N个字段中进行选择,该怎么办?其中每一个都是可以解决的......但是报告会变得更加复杂。

But it won't extend nicely. What if the 2 fields are different data types? What if you want to let the user choose from 3 or 4 or N fields? Each of those is solvable... but the report becomes exponentially more complex.

顺便说一句,这是相对常见的请求。你会看到像这样的功能进入JasperReports。但现在这是一个艰难的。

By the way, it's relatively common request. You'll see features like this make their way into JasperReports. But for now it's a tough one.

这篇关于JasperReports分组可由用户更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆