为什么在使用subDataSource()时,子报表仅从JsonDataSource中获得一行? [英] Why does subreport only get one row from a JsonDataSource when using subDataSource()?

查看:67
本文介绍了为什么在使用subDataSource()时,子报表仅从JsonDataSource中获得一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个干净的Jasper报告,该报告调用了没有过滤器的子报告. 在该子报表中,我显示了所有的Json数据(10行),如果我看到了预览,它将起作用:子报表预览.

I have a clean Jasper report that calls a subreport with no filter. In that subreport I show all the Json data (10 rows), and if I see the preview it works: Subreport preview.

问题是当我从主(干净的)报告中调用子报告时.它仅详细包含professionalName和子报表.它应该显示professionalName和所有subReport(每次都显示10行),但实际并非如此.它只显示当前行,我敢肯定这是因为主报表并未将所有数据源仅提供给子报表,而是提供给了子报表.捕获的内容如下:主报告预览.

The problem is when I call the subreport from the main (and clean) report. It only has in the detail the professionalName and the subreport. It should show the professionalName and all the subReport (all 10 rows each time), but it's not the case. It only shows the current row, and I'm sure it's because the main report is not giving all the datasource to the subreport, only that row. Here is the capture: Main report preview.

数据源表达式为:

<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource()]]></dataSourceExpression>

Json文件就是这个文件:

and the Json file is this one:

[   {
        "appointmentId": 153,
        "startDate": 1503061200000,
        "patientId": 417,
        "patientIdentification": {
            "id": 1,
            "name": "85471254B"
        },
        "episodeId": 500358,
        "chn": "500058",
        "patientName": "Aida Mascaró",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "NEUROLOGIA",
        "benefitId": 45,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 30,
            "name": "Neurologia"
        },
        "professionalName": "a",
        "insurance": {
            "id": 1387,
            "name": "PRIVADOS"
        },
        "collective": {
            "id": 26,
            "name": "Privados"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {
            "id": 3,
            "name": "Accidente de trabajo"
        },
        "appoState": {
            "id": 3,
            "name": "Atendiendo"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503057809579
    },
    {
        "appointmentId": 150,
        "startDate": 1503039600000,
        "patientId": 405,
        "patientIdentification": {
            "id": 1,
            "name": "40295204D"
        },
        "episodeId": 500349,
        "chn": "500046",
        "patientName": "Cristina Mayo Saez",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "ENDOCRINOLOGIA",
        "benefitId": 28,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 26,
            "name": "Nutrición"
        },
        "professionalName": "b",
        "insurance": {
            "id": 1387,
            "name": "PRIVADOS"
        },
        "collective": {
            "id": 26,
            "name": "Privados"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {},
        "appoState": {
            "id": 3,
            "name": "Atendiendo"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503037036812
    }, {
        "appointmentId": 151,
        "startDate": 1503039600000,
        "patientId": 416,
        "patientIdentification": {
            "id": 1,
            "name": "18466341D"
        },
        "episodeId": 500350,
        "chn": "500057",
        "patientName": "Gloria Sena Arrayán",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "NEUROLOGIA",
        "benefitId": 45,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 30,
            "name": "Neurologia"
        },
        "professionalName": "b",
        "insurance": {
            "id": 1396,
            "name": "AGRUPACION MUTUAL ASEGURADORA (AMA)"
        },
        "collective": {
            "id": 30,
            "name": "Trafico"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {},
        "appoState": {
            "id": 4,
            "name": "Atendido"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503038643436
    },  {
        "appointmentId": 154,
        "startDate": 1503298800000,
        "patientId": 389,
        "patientIdentification": {
            "id": 1,
            "name": "23234567J"
        },
        "episodeId": 500359,
        "chn": "500030",
        "patientName": "maria perez perez",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "ENDOCRINOLOGIA",
        "benefitId": 28,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 26,
            "name": "Nutrición"
        },
        "professionalName": "a",
        "insurance": {
            "id": 1387,
            "name": "PRIVADOS"
        },
        "collective": {
            "id": 26,
            "name": "Privados"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {
            "id": 2,
            "name": "Accidente causal"
        },
        "appoState": {
            "id": 3,
            "name": "Atendiendo"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503297627789
    }, {
        "appointmentId": 148,
        "startDate": 1503300600000,
        "patientId": 415,
        "episodeId": 500346,
        "chn": "500056",
        "patientName": "Pastora Meseguer Carrión",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "NEUROLOGIA",
        "benefitId": 45,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 30,
            "name": "Neurologia"
        },
        "professionalName": "a",
        "insurance": {
            "id": 1387,
            "name": "PRIVADOS"
        },
        "collective": {
            "id": 25,
            "name": "Privados todos"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 7,
            "name": "No requerida"
        },
        "reason": {},
        "appoState": {
            "id": 4,
            "name": "Atendido"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1502885871664
    },  {
        "appointmentId": 152,
        "startDate": 1503302400000,
        "patientId": 416,
        "patientIdentification": {
            "id": 1,
            "name": "18466341D"
        },
        "episodeId": 500351,
        "chn": "500057",
        "patientName": "Gloria Sena Arrayán",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "NEUROLOGIA",
        "benefitId": 46,
        "benefitName": "REVISION",
        "schedule": {
            "id": 30,
            "name": "Neurologia"
        },
        "professionalName": "a",
        "insurance": {
            "id": 1396,
            "name": "AGRUPACION MUTUAL ASEGURADORA (AMA)"
        },
        "collective": {
            "id": 30,
            "name": "Trafico"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {},
        "appoState": {
            "id": 4,
            "name": "Atendido"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503038674027
    },{
        "appointmentId": 156,
        "startDate": 1503302400000,
        "patientId": 389,
        "patientIdentification": {
            "id": 1,
            "name": "23234567J"
        },
        "episodeId": 500361,
        "chn": "500030",
        "patientName": "maria perez perez",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "PEDIATRIA",
        "benefitId": 3,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 29,
            "name": "Dra. De la Vega"
        },
        "professionalName": "a",
        "insurance": {
            "id": 1387,
            "name": "PRIVADOS"
        },
        "collective": {
            "id": 26,
            "name": "Privados"
        },
        "typeId": 1,
        "observations": "obs",
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {
            "id": 2,
            "name": "Accidente causal"
        },
        "appoState": {
            "id": 3,
            "name": "Atendiendo"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503300374408
    },{
        "appointmentId": 142,
        "startDate": 1503298800000,
        "patientId": 412,
        "episodeId": 500337,
        "chn": "500053",
        "patientName": "Mariano López Pastor",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "NEUROLOGIA",
        "benefitId": 45,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 30,
            "name": "Neurologia"
        },
        "professionalName": "b",
        "insurance": {
            "id": 1387,
            "name": "PRIVADOS"
        },
        "collective": {
            "id": 25,
            "name": "Privados todos"
        },
        "typeId": 1,
        "guarantorStatus": {
            "id": 7,
            "name": "No requerida"
        },
        "reason": {},
        "appoState": {
            "id": 4,
            "name": "Atendido"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1502877885393
    },  {
        "appointmentId": 158,
        "startDate": 1503303300000,
        "patientId": 408,
        "patientIdentification": {
            "id": 2,
            "name": "123123"
        },
        "episodeId": 500363,
        "chn": "500049",
        "patientName": "ANA CARO MARTINEZ",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "PEDIATRIA",
        "benefitId": 3,
        "benefitName": "CONSULTA",
        "schedule": {
            "id": 29,
            "name": "Dra. De la Vega"
        },
        "professionalName": "b",
        "insurance": {
            "id": 1749,
            "name": "ADMIRAL INSURANCE"
        },
        "collective": {
            "id": 13,
            "name": "Trafico"
        },
        "typeId": 1,
        "observations": "dewdfe",
        "guarantorStatus": {
            "id": 1,
            "name": "Solicitada"
        },
        "reason": {
            "id": 2,
            "name": "Accidente causal"
        },
        "appoState": {
            "id": 3,
            "name": "Atendiendo"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503301904789
    }, {
        "appointmentId": 159,
        "startDate": 1503304200000,
        "patientId": 48,
        "patientIdentification": {
            "id": 5,
            "name": "1425871"
        },
        "episodeId": 500364,
        "chn": "186",
        "patientName": "cayetana jimenez brotons",
        "centerName": "HOSPITAL CLINICA BENIDORM",
        "serviceName": "PEDIATRIA",
        "benefitId": 4,
        "benefitName": "REVISION",
        "schedule": {
            "id": 29,
            "name": "Dra. De la Vega"
        },
        "professionalName": "b",
        "insurance": {
            "id": 1390,
            "name": "MAPFRE ESPAÑA, CIA. DE SEGUROS Y REASEGUROS S.A."
        },
        "collective": {
            "id": 4,
            "name": "MAPFRE SALUD"
        },
        "typeId": 1,
        "observations": "dfd",
        "guarantorStatus": {
            "id": 7,
            "name": "No requerida"
        },
        "reason": {
            "id": 2,
            "name": "Accidente causal"
        },
        "appoState": {
            "id": 3,
            "name": "Atendiendo"
        },
        "appoType": {
            "id": 1,
            "name": "Simple"
        },
        "professionalCreationName": "Marisol Fernández Lleras",
        "creationDate": 1503301999486
    }
]

如何为显示的每一行传递整个数据集?谢谢

What can I do to pass the whole DataSet for each row I show? Thank you

推荐答案

The subDataSource method uses the current node when creating a new JsonDataSource instance. A future version of JasperReports will address this issue, but until then, you need to:

  1. 从子报表中删除Data Source Expression.子报表本身将使用JSON数据适配器.
  2. 将JSON数据适配器导出到文件.如果您以前从未在Jaspersoft Studio中进行过操作,请参见此处中的步骤2.
  3. 在子报表中,将报表的Default Data Adapter属性设置为指向上一步中保存的适配器.请参阅此处中的步骤4.
  4. 如果要注意自动构建项目,请重新编译子报表.
  1. Remove the Data Source Expression from your subreport. The subreport itself is going to use a JSON data adapter.
  2. Export your JSON data adapter to file. See step #2 from here in case you haven't done it before in Jaspersoft Studio.
  3. In your subreport, set the report's Default Data Adapter property to point to your saved adapter from previous step. See step #4 from here.
  4. Recompile your subreport if you're note building the project automatically.

这篇关于为什么在使用subDataSource()时,子报表仅从JsonDataSource中获得一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆