0

I want to create 3 tables (in single report) from single json based dataset.

I'm able to create one table but while creating another I'm not sure what to use in datasource connection

For creating the first table I have used $P{REPORT_DATA_SOURCE} as datasource connection while binding dataset to table, but for second and third tables I'm not sure how to bind that single dataset with all 3 tables

consider below json:

[
  { 
    "name": "HSBC Mandatory Provident Fund - SuperTrust",
    "Type of Transfer-in Accounts": "PA",
    "1": 5,
    "2": 5,
    "3": 5,
    "4": 5,
    "5": 5,
    "6": 5,
    "7": 5,
    "8": 5,
    "9": 5,
    "10": 5,
    "11": 5,
    "12": 5,
    "13": 5,
    "14": 5,
    "15": 5,
    ">7": 5,
    "total": 35}
]

expected output: expected output

now below this table i want to create another table but instead of 1 to 7 days i want to show data of 8 to 15 from json thats it

  • 2
    Possible duplicate of [How to create multiple tables in jasper report using json as a datasource?](https://stackoverflow.com/questions/34603844/how-to-create-multiple-tables-in-jasper-report-using-json-as-a-datasource), it's very close to your example, the key is to *subDataSource*, your question does not have desired ouput, so better then this is hard to give you. – Petter Friberg Jun 21 '17 at 15:17
  • what if i dont want to use subreport, the option that u suggested is having sub report.i just want to use single data source and create tables in single report, lets say in one table i want to use 5 column of that json source and in another table i want to use 10 column of that json source kind of – pranav joshi Jun 22 '17 at 08:27
  • same stuff, just replace the subreport with the jr:table component, both subreport and jr:table can take a "sub" datasource. – Petter Friberg Jun 22 '17 at 08:33
  • I have tried but it is not showing anything – pranav joshi Jun 22 '17 at 09:46
  • Can you show the expected output, your current json does not seem very adapt to have subdatasource it has no array structure for the data of the different names. – Petter Friberg Jun 22 '17 at 10:00
  • i have edited the question,attached picture is what i am displaying right now,i want to create another table within the same report but with different field that will come from json(as of now i have put only one object in json for understanding,but in real multiple object will come in same format).so lets say in first table i have picked up 7 field from json and displayed it to one table and in another table i want another 7 field to be displayed using the same datasource and i am using simple json structure that is the reason i want to avoid subreport – pranav joshi Jun 22 '17 at 10:59
  • Your json is not very well fit to do what you like, the only method I can see is to clean your datasource and then add the 2 table's each with a different datasource. The other solution is to change the json to be more adapt for this kind of visualizzation – Petter Friberg Jun 22 '17 at 12:10
  • i have tried creating 2 datasets with the same json file,and then bind it with table,but then it is only populating first table.second table showing null values..i have used $P{REPORT_DATA_SOURCE} while binding table to dataser..i hope u got my question what i want to do? – pranav joshi Jun 22 '17 at 12:34
  • If you pass from java pass the 2 datasource in 2 different parameters – Petter Friberg Jun 22 '17 at 14:38

0 Answers0