Jump to content
We've recently updated our Privacy Statement, available here ×

add Combobox/list/dropdown parameter to Ireport report


rodnikosh
Go to solution Solved by rodnikosh,

Recommended Posts

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 prompt when i preview the report and the string inserted into the query and 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`

i tried to make the city_combobox parameter a "Java.util.list" but i get "Parameter type not supported" error and also i don't know where to load the strings into it.

 

by the way, i don't know anything about Jasperreport server, i didn't install it, only Ireport is installed and up to know i did everything with it,

so i'm looking for a way to do that in Ireport only, without an intput control of jasperreport server.

it will be even enough for me to just provide the report with a manully inserted values into the combobox,

it doens't have to be even a query. for example, insert somewhere "NY","Miami", "Washington" into a list parameter,

but how and where do i do that?

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Refer following query

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
     $X{IN, leads.`primary_address_city, city_combobox}

GROUP BY
     leads.`status`

City_combobox with datatype java.util.collection.

Link to comment
Share on other sites

thank you, but this causes the report to present a result that includes all the cities together. and also , where is the combobox that enables me to choose which city?.

when i preview ther report i get to insert a string. i don;t see any combobox with the city. what did i forget?

 

Link to comment
Share on other sites

Thank you very much for all your help, i solved the problem. i didn't use the solution you gave but it helped me keep an open mind to find the right one.

as i said, i use zuckerreport component in SugarCRM to run the reports i create in Ireport. it turns out zuckerreport is actually "kind of" a jasperreport server!. all i needed to do is go deeper into learning zuckerreport and to find that it can add input controls too , just like jasperreport server. so i'm posting my solution as an answer. thank you.

Link to comment
Share on other sites

  • Solution

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

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.

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

for a dropdown parameter choose a 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
leads leads

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

The 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',
  ),

then you'll see the hidden fields.

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

a. Choose a name for the template and choose the jrxml file of the report (from local computer where the Ireport is).
b. Choose PDF.Excel and HTML.
c. Save
 

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”

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.

There you go! :)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...