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

Jasper Report: Adding dropdown and searchbox to the jasper report template


milindk740

Recommended Posts

I have a requirement wherein I have to add a search box and dropdown to jasper report which displays user details. I am using iReport to create jasper template. Can we add a search box and dropdown to the template itself? The report will be rendered in the HTML format on the UI displaying the user details. Now the task of the search box would be to display the details of the specific user that the client inserts in the search box. I could not find any element to do so. Can any one help.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi,

Can we add a search box and dropdown to the template itself? 
I am assuming that you are using to create your reports using iReport, so there we can add parameters which could be filled via Jasper server using the UI of the filters, as far as I know we cannot add the UI components like dropdown or search box in the template.

Now the task of the search box would be to display the details of the specific user that the client inserts in the search box
This could be achieved by setting up the query to retrieve the records  in creating the IMPUT CONTROLS in Jasper Server and there we could get the drop down or search box to find or list the different users or whichever list of people are added to be selected as filter.

Hope that this helps.

Thanks
Ankur Gupta
http://ankurthetechie.blogspot.in/

Link to comment
Share on other sites

Hi,

As you want to integrate Jasper Reports in the a Java web application then what could be done is that use the iReport to design the reports, so you will have JRXML file of the report now as you require the value from the application via Search box or Dropdown so you can place these in the application and Java you can simply set the parameters of the report created in iReport via java program , and then again via the same program you can execute the report with aggregated paramters from the search box and drop down, 

now for comipling and setting the parameters in the report (JRXML file) programatically via a java program you need to make of the package net.sf.jasperreports.engine.design contained in the jar file jasperreports-x.x.x.jar (x defines the version of the jar).

This Jar file could be easily find in the directory where the iReport is installed. (Location where iReport is installedireportmodulesext)

A sample for the code is 

Class.forName("com.mysql.jdbc.Driver");[/code]
Connection conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/student","username","pass");[/code]
ResultSet rs=conn.createStatement().executeQuery("SELECT * FROM student_details "); [/code]
JRResultSetDataSource  jrrsds= new JRResultSetDataSource(rs);[/code]
JasperDesign jasperDesigns = JRXmlLoader.load("Path of the JRXML rport created by iReport");[/code]
JasperReport jasperReports = JasperCompileManager.compileReport(jasperDesign);[/code]
JasperPrint jasperPrints = JasperFillManager.fillReport(jasperReports, new HashMap(),jrrsds);[/code]
JasperExportManager.exportReportToHtmlFile(jasperPrint, "Path to export as HTML") ;[/code]
JasperViewer.viewReport(jasperPrint); // Could be set wherever you want to view the report[/code]


Hope that above information helps.

Thanks,
Ankur Gupta
http://ankurthetechie.blogspot.in/

 

 

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...