3

I have a report in JasperReports Server 5.2.0, in this report I have two input control

first one is:

COUNTRY (value column- COUNTRY_ID, visible column- COUNTRY_NAME) 

and another one is

STATES (value column- STATE_ID and visible column - STATE_NAME).

These two parameters I am passing to the report, now at the end of the report I want to show the input parameter selection value so user can see what he has selected. But I am not able to get the visible values of parameters. I can print only value column value.

So my question is there any way to print the visible column values of input control in reports?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Sharad
  • 3,562
  • 6
  • 37
  • 59
  • This issue is already open: [Pass back Visible Columns/ListValues from multi-select and single select to the jrxml file as parameters.](http://community.jaspersoft.com/jasperreports-server/issues/4347). You can give a voice on it – Alex K Aug 23 '13 at 08:32
  • Try this solution: [Input controls](http://community.jaspersoft.com/questions/529170/input-controls). It is about using paira of both values as *value column* (for example, separated by delimiter) and extracting the one part or another – Alex K Aug 23 '13 at 08:35
  • You will get ids of States and Country in JRML file.Write a subquery for it.Then you will get those details to print in Report – Subin Chalil Oct 16 '15 at 12:30

1 Answers1

0

Till now , Visible Columns are not passed,where Value Columns are passed to Jrml File in Jasper.

 To answer you question There is a way to print the visible column values.
It can be done using Sub-queries, by using 'Value Column' passed to the JRML file.
Then add the subquery to your main query and it`s done!!

In the above scenario You can display

  1. State Name

SELECT States.STATE_NAME from States WHERE state_id = $P{STATE_ID} - If it is Single Select input control

SELECT GROUP_CONCAT(States.STATE_NAME) from States WHERE state_id = $X{IN,state_id,STATE_ID} - If it is Multi-Select input control

  1. Country Name

SELECT Country.COUNTRY_NAME from COUNTRY WHERE country_id= $P{COUNTRY_NAME} - If it is Single Select input control

SELECT GROUP_CONCAT(Country.COUNTRY_NAME) from COUNTRY WHERE country_id = $X{IN,state_id,STATE_ID} - If it is Multi-Select input control


Suppose this your main query where Country and State are missing..

SELECT
    `id`,
    `product-id`,
    `name`,
    `description`,
    `branch`,
    `stock`,
    `price`
FROM
    `products`
WHERE
    `name` LIKE "%car%"

The modified query will looks like..

    SELECT
        `id`,
        `product-id`,
        `name`,
        `description`,
        `branch`,
        `stock`,
        `price`,
        (SELECT States.STATE_NAME from States WHERE state_id = $P{STATE_ID}) as state,
(SELECT Country.COUNTRY_NAME from COUNTRY WHERE country_id=P{COUNTRY_NAME}) as country
    FROM
        `products`
    WHERE
        `name` LIKE "%car%"
Subin Chalil
  • 3,531
  • 2
  • 24
  • 38