nileshravinaik Posted August 28, 2014 Posted August 28, 2014 I need to hide a element on the main report based upon a field (say X) defined in the new dataset created on the main report. But the problem is, I cannot hide this element as this field X is not appearing under print when expression. Only fields identified on the main report query are showing up here.So how do I hide this element now? Note, I cannot add the query from the dataset (which retrives this field X) to the main report query as that query already returns some other data from the DB.
Solution ecanaveras Posted August 29, 2014 Solution Posted August 29, 2014 HI,You can not return values from a datasetUse subreport... Regards
eliasjrjos Posted May 22, 2018 Posted May 22, 2018 I have found this solution at stack over flow and this is the link :https://stackoverflow.com/questions/10394401/how-to-return-value-from-tables-datasource-to-main-report-in-ireportIf you want to get some data from the table dataset, you actually can do this. I found a dirty trick to achieve this.Create VARIABLE variableMapName of type java.util.Map in main report and initialize it with expression new java.util.HashMap()Create PARAMETER parameterMapName of type java.util.Map within table datasetLink dataset PARAMETER with variable from main report using "Edit table datasource -> Parameters -> Add -> $P{parameterMapName} = $V{variableMapName}" (right click on the table in main report template)Create variable putResult of type java.lang.String in table datasource. Expression for this variable will looks like this$P{parameterMapName}.put("KEY", $F{fieldYouWantReturn}) + $P{parameterMapName}.put("KEY2", $F{otherFieldYouWantReturn})Now you have an ability to use the data from table datasource in main report by using $V{variableMapName}.get("KEY")It is really a dirty hack, but sometimes you have no other way to do something. Thanks!
amlan.samanta Posted June 25, 2020 Posted June 25, 2020 Kindly participate in the discussion to achieve a solution:https://community.jaspersoft.com/wiki/how-pass-variable-value-sub-dataset-main-dataset#comment-867191
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now