如何为Ireport中的多选参数的空值赋值? [英] How to give condition for null values of multi select parameter in Ireport?

查看:176
本文介绍了如何为Ireport中的多选参数的空值赋值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 iReport 开发报告,我想在其中添加条件对于空值。它使用单选项作为:

I am developing a report using iReport where I want to add a condition for null values. It's working with single select option as:

(city=$P{p_city} or $P{p_city} is null)

这意味着如果我们没有传递city参数的任何值,报告将会起作用,但是这个多选选项不起作用。我们在创建参数时必须在iReport中选择Collection值表达式:

It means here if we do not pass any value for the city parameter, the report will work, but this is not working in case of a multiselect option. We have to choose a "Collection" value expression in iReport when we create a parameter:

($X{IN, country,p_country} or $P{p_country} is null) 

我在 JasperReports Server 来运行此报告。一个是单选,选择城市,另一个是多选,选择国家,报告正在运行而没有传递选择城市参数的值,但对于选择国家参数,我们必须传递该值,因为选择国家/地区是多选项和集合类型参数,并且您不能在查询中为城市参数添加空条件。

I have created two input controls in JasperReports Server to run this report. One is a single select, "Select City" and the other is a multi select, "Select country", and the report is running without passing a value for the "Select city" parameter, but for the "select country" parameter, we must pass the value, because "Select country" is multi select and a Collection type parameter and you can not add null condition in a query as for the city parameter.

如何我们可以修改 JRXML 查询吗?

How we can modify the JRXML query?

推荐答案

$ X功能会自动处理。在您的情况下,您在查询中有这个:

The $X feature handles this automatically. In your case you have this in your query:

$X{IN, country, p_country}

如果您的Collection为null,则转换为 1 = 1 。所以没有理由在查询中添加 $ P {p_country}为空

That gets converted to 1 = 1 in the case where your Collection is null. So there is no reason to add $P{p_country} is null into the query.

这篇关于如何为Ireport中的多选参数的空值赋值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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