Dynamic Query in JasperReport - jasper-reports

I am new to JasperReports and I am trying to build a "dynamic report".
In JasperREports ultimate guide it's said that we can pass table names and table columns names as parameters using $P!{paramName} Syntax:
<queryString>
<![CDATA[
SELECT * FROM $P!{MyTable} ORDER BY $P!{OrderByClause}
]]>
</queryString>
I have created different views of my table for different period aggregations.
Then I am trying to pass the view's name as a parameter so that I can choose which period to display in the report BUT with no success.
Can anybody help me?

In order to help you, we must know the error you are retrieving, how do you execute the report (within iReport? through a Servlet? using JasperServer?) Are these parameter instanciated? you can begin by outputing the query string, or the parameters themselves in the report, to see what sentence are you using to retrieve your dataset...

Related

Prevent grouping column header in JasperReports

i want to make an Crosstab Template for my data.
For each value there is a timestamp, a location and the name of the device from which i get the value. So i am giving a list of values via Java and a JRBeanCollectionDataSource to my report, for the example below this would be 9 values while each of them has 3 additional parameters to place it on the right column/place in the crosstab.
When i give this sort of data to my Jasper Report with a Crosstab (Crosstab is needed cause i don't know how many rows and columns my report will have) in it, Jasper orders/groups the columns and the output looks like this:
But what i want is to show the data in the sequence i give them to my report, for example:
I am using Java to fill my report with a JRBeanCollectionDataSource and a self defined DataSource (this works perfect, i am working with this method for months).
Is there any way this kind of column grouping could be prevented? (i have a working crosstab template but i am not able to find the propertie with the help of i can solve my problem)
Hope you people can help me.
Have you tried to tell the crosstab that your data ir already sorted?
http://jasperreports.sourceforge.net/schema.reference.html#crosstabDataset
Click the crosstab element, in the Dataset Tab, mark "Data Pre Sorted".

Need help in report's dataset

I'm using iReport Professional 5.1.0. I already used one query (some select query) in report query. But i need to use multiple queries in same report. So i tried with dataset. After creating dataset (Report Inspector -> right click Add Dataset), I've created different query. But i cant get any parameters (which is assigned to parent query column) to the newly created dataset.
My doubt is whether the dataset is applicable only to table, chart and crosstabs. If no, then explain step by step procedure to use dataset in iReport.
Parameters should be in each datasets so just copy the parameters from parent dataset and paste it in all the datasets and when you use any sub dataset for any chart, table or crosstables just pass all parameters and Expression for that parameter.

HTML column sorting in report generated by JasperReports

Can we have column sorting in report which is generated (in html format) by iReport for example
if a report contains three column name, age, sex
and i want to sort report on clicking on age than it should sort based on age.
If you don't can use the table component (table component have this in native function), you can create a link this mode:
One idea is in your column header you create a link to the same report and send parameter with number of column in your SQL, after you can use this in your sql or procedure to sort.

Jasper Server: passing argument to get report data for customer

I have almost the problem described here: iReport: Passing parameters from a main report query to a dataset query for a table or list
but since it's a few years old, I'm using iReports 5.1 with the newest comnunity version of Jasper Server.
I am able to fetch reports by PHP from the server, but I want to pass a parameter to the report to only display information for a distinct customer, having something like customerId in the database. So it only generates a report for a give customerId.
I don't want to create a single report for every customer.
How can I pass arguments to the datasource/main report, through the API?
Additional question: Is it possible to add this argument/parameter to scheduled reports?
Add to the report (XML):
<parameter name="CUSTOMERID" isForPrompting="false" class="java.lang.String">
</parameter>
In the datasource (mongodb):
{'collectionName':'test', findQuery : { customerId: $P{CUSTOMERID} }}
passing the argument:
ws_runReport($currentUri, $report_params, $output_params, $attachments);
Hope this will help someone else, too.

JasperReport parameters works in iReport but fails on JasperServer

I have a report created in iReport. Have a parameter set with isForPrompting="true". When I go and test it with preview, everything works.
Parameter: Symbol
SQL Query: select * from "table" where "column" = $P{Symbol} -- I'm using Postgres.
Then I use Repository Navigator to upload it to the server. The server returns "no pages" Any thoughts. I've verified that the report work in both iReport and JasperServer if parameter is removed and the value is hard coded into to the sql query like below.
<queryString>
<![CDATA[select * from "tablename" where "column" = 'testsymbol']]>
</queryString>
Yes, it was the input control. It's working now... thanks #precose!!!