将组合框参数添加到iReport的报告中 [英] Add combobox parameter to iReport's report

查看:95
本文介绍了将组合框参数添加到iReport的报告中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iReport 4.8.0 中,我想让用户从Combobox / list / Dropdown / collection(你选择的任何东西)中选择一个参数值,然后插入他选择的值进入查询。

In iReport 4.8.0, I want to enable the user to choose a parameter value from a Combobox / list / Dropdown / collection (whatever you choose) and the value that he chooses will be inserted into the query.

我已经创建了一个字符串参数,在我预览报表并将字符串插入查询时会提示。它工作得很好,但现在我需要定义一个组合框。

I already created a string parameter that prompts when I preview the report and the string is inserted into the query. It works great, but now I need to define a combobox.

我需要提供城市名称,所以我的查询是:

I need to provide names of cities so my query is:

SELECT
  COUNT(leads.`status`) AS Number_Of_Status,
  leads.`status` AS leads_status,
  leads.`primary_address_city` AS leads_primary_address_city,
  leads.id AS lead_id
FROM
      `leads` leads
 WHERE
      leads.`primary_address_city` = $P{city_combobox}
 GROUP BY
      leads.`status`

我试过使 city_combobox 参数a java.util.List 但是我得到不支持参数类型错误,我也不知道在哪里加载字符串。

I tried to make the city_combobox parameter a java.util.List but I get Parameter type not supported error and I also don't know where to load the strings into it.

我对 JasperReports Server <一无所知/ em>,我没有安装它,只安装了 iReport ,最多知道我用它做了一切。

I don't know anything about JasperReports Server, I didn't install it, only iReport is installed and up to know i did everything with it.

所以我'我正在寻找一种方法来做到这一点 iReport ,没有 JR服务器的输入控件。对于我来说,只需在报告框中提供手动插入的值就足够了,它甚至不必是查询。例如,将NY,Miami,Washington插入列表参数,但是我如何以及在何处进行此操作?

So I'm looking for a way to do that in iReport only, without an input control of JR Server. It will be enough for me to just provide the report with a manually inserted values into the combobox, it doesn't have to even be a query. For example, insert "NY","Miami", "Washington" into a list parameter, but how and where do I do that?

推荐答案

我解决了这个问题。事实证明,zuckerreport基于jasperreport服务器,因此也可以添加输入控件。

i solved the problem. it turns out zuckerreport is based on jasperreport server and therefore can add input controls too.

解决方案是创建city_combobox参数作为字符串参数并保留查询就像我给出的上述例子一样。那就是IReport。

The solution is to create the "city_combobox" parameter as a string parameter and leave the query as is , like the above example i gave. thats it for the IReport.

在zuckerreport中,添加一个名为city_combobox的默认参数名称参数。

in zuckerreport, add a parameter that its "Default Parameter Name" named city_combobox.

对于下拉参数选择用户定义查询类型的参数,并使用查询填充参数设置和用户定义查询字段,该查询将使用值列表填充下拉列表,例如:

for a dropdown parameter choose a parameter of type of "user-defined Query" and fill the "Parameter Settings" and "User-Defined Query" fields with a query that will fill the dropdown with a list of values, for example:

SELECT DISTINCT
leads.primary_address_city AS leads_primary_address_city
FROM
lead lead

SELECT DISTINCT leads.primary_address_city AS leads_primary_address_city FROM leads leads

如果你看不到参数设置和用户自定义查询字段(在新版zuckerreport中它们被隐藏),那么

if you can't see the "Parameter Settings" and "User-Defined Query" fields (in the new version of zuckerreport they are hidden), then

这个需要在zuckerreport的editview代码中手动添加代码。
在modules / zr2_ReportParameter / metadata / editviewdefs.php中添加此代码:

This code is needed to be added manually in the editview code of zuckerreport. Add this code in modules/zr2_ReportParameter/metadata/editviewdefs.php :

5 =>
array(
0 =>' range_options',
),

5 => array ( 0 => 'range_options', ),

现在重建,然后你会看到隐藏的字段。

now rebuild and then you'll see the hidden fields.

使用菜单上的jasperReports Template创建一个新模板,模板实际上就是报告:

Create a new template using "jasperReports Template" on the menu, the template is actually the report:

a。选择模板的名称,然后选择报告的jrxml文件。
b。选择PDF,Excel和HTML。
c。保存

a. Choose a name for the template and choose the jrxml file of the report . b. Choose PDF , Excel and HTML. c. Save

在报告和参数之间创建一个新的参数绑定:
a。按创建
b。参数名称必须是IReport中的确切参数名称。
c。选择报告和参数,无需选择绑定到模块

Create a new Parameter binding between the report and the parameter: a. Push "Create" b. The parameter name has to be the exact parameter name in the IReport. c. Choose the report and the parameter and no need to choose "Bind to module"

将报告的.jasper文件复制到SugarCRM中的custom / zuckerreports2 / resources中。
转到按需报告,选择报告并显示参数。

Copy the .jasper file of the report into custom/zuckerreports2/resources in SugarCRM. Go to "On demand reporting", choose the report and the parameter is supposed to show.

你去了! :)

这篇关于将组合框参数添加到iReport的报告中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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