Passing field values to table component - jasper-reports

I have a problem with a report, I pass a array of values to report (from Java code) and that information is loaded inside the report (that works fine). But, I need to pass that field values to a table component, I saw and I can pass parameters to table, but I need use the main field values inside of table component and print that data there (in table component).

I suppose you pass the data from java as datasource. You have to pass the datasource for the table in a parameter and run the report with a different datasource (may be empty if you don't need any data). Then set the table datasource to be that parameter and declare the fields in the subdataset of the table.
See
How to show JRBeanCollectionDataSource data with help of Table component?
or
Two DataSource in report
for examples.

Related

Use SQL Select directly in CR Function

There's a working report but I wan't to change the visibility of certain rows based on a completely new DB select that should be executed when the report is created.
It would be ideal, if I could load the values of said select in an array or a list and than simply trigger certain row's visibility by comparing e.g. the Row Id with the values in the array.
Im used to solve a problem like this by creating a View that delivers all the essential information in each row and is used as the main data source but I was wondering if there's an elegant way within crystal reports to solve such a task.
I can think of three ways to include control data like this into the report:
One row of config data: If you can arrange it that your config data query returns one row of data, it can be just added to the data sources of the main report, without any links to tables and views already there.
Config resultset for matching: If you have to match main data results to config values row by row, e.g. by the Row Id you mentioned, add this config query to your report and link it to the main data source accordingly. (You are probably already doing this within your pre-created view on database side.)
Query config by subreport: Most flexible but also time consuming option is to add a subreport in report header, add the config data query and arrange config results into (shared) variables as needed in the subreport. Shared variable values can be used in main report then to control section visibility.
Yes, one of the 3rd-party Crystal Reports UFLs (User Function Libraries) listed here provides such a function.

Jaspersoft Table Element No data displayed

I have a table component on a subreport being used with an independent data source (dataset) thats hooked onto the table object. The table has two columns, the following issues arise upon debugging:
Not all descriptions are loaded from the query I used
The second column is not showing the data at all
Is there any properties that I am missing?
Thank you
Kind reagrds
Zain Nabi
Jasperstudio reports require all parameter names to be the same.

How to Show/Hide Table Object Columns

I am working in iReport 5.6.0. I am creating a report base utilizing a table and would like to build one or more options to hide a series of columns; effectively creating a master report which will allow users to have multiple report views based on a simple parameter selection. In theory, this should work. However, I am having a problem passing a parameter from the main report it the table (where I am would use it to activate the Column Print When property.
To be clear. I have created an outer parameter and an inner parameter. I have also successfully mapped the parameters. I know that the mapping is working as I have added a column to my table and placed the parameter within the data row so that I can visually evaluate it--this too, works. However, when I set the Column Print When property as
$P{parameter1_1}.equals("y")
or even
$P{parameter1_1}.equals('y')
and then preview the report, I receive the following error:
Parameter not found: Description: parameter1_1 Object: fx $P{parameter1_1}.equals("y")

JasperReports JRXML FiIl subDataSet with data

I'm trying to fill subdataset with data. I want to take data from my variable/property, fill dataset and retrieve data from dataset, using $F{field_name}. It is possible?
Yes you can fill the subdataset from main dataset. These are some steps to fill the sub dataset:-
Suppose we have field field_name in main data set and now we want to pass to the sub data set-
Create a parameter $P{p_field_name} and add the default value $F{field_name} in main dataset.
Then edit the query of sub dataset and create parameter $P{pm_field_name} and add the default value $P{p_field_name}
From my experience is not possible to fill a subdataset without using a chart or a list component. If that's your case you can see how to use a list in this video. If you need it for a chart is like this
Otherwise use a subreport and passing your $F{field_name} as datasource, it is explained here

JasperReports: dynamic report generation

I am new to JasperReports. I need to design a report where certain columns and rows are dynamic. For this how I have to design the report and after design i want to integrate with my application for fetching data from action class and dto. How to map data for its?
I don't know how dynamic it will be, but it may help you: http://dynamicjasper.com/
It uses JasperReports to generate your report and it also allow you to create your report on the fly.
There are 2 options to map data with the columns. First option is u can pass ur data into data Source binding with the column name as key value pair. And the second option is u can pass the obj of your dto to data source directly in list form.
Use report.setDataSource() for setting the data. In first option make sure your type of the data matches with the column name.