Pass updated information from subreport to parent report

Asked

Viewed 818 times

1

I am making a report that contains all service providers, and has the following hierarchy: City -> Specialty -> Provider.

In the ireport stood the main report containing a city subreport, within the city subreport has a subreport of specialties and within the specialties has a subreport of all service providers.

My problem is in the main report that you need each page to have the name of the city and on the side the name of the specialty. Pass information from the subreport to the main report I can, through a variable, I just can’t put in the header because it is compiled before the band that is the subreport of cities, and when I put in another band it only shows the name of the last city. And also put the specialty name on the side in the same way as the name of the city.

The report has a pattern to follow, which is according to an example I made to follow. Example

1 answer

1


I do not think it is necessary to create a three-level report. You can solve this by creating a query that makes the Join of the three tables and create two groups, one for city and one for specialty.

As I don’t know your model, I will draft an example query:

select c.nome as nome_cidade, e.titulo as titulo_especialidade,
       p.codigo as id_prestador, p.nome as nome_prestador, p.info as info_prestador
  from cidade c
  join especialidade e
       on e.codigo_cidade = c.codigo
  join prestador p
       on p.codigo_cidade = c.codigo
       and p.codigo_especialidade = e.codigo
  order by c.nome, e.titulo, p.nome

Following this example, now just create groups in iReport (not in the query), namely a group by the value of $F{nome_cidade} and another by $P{titulo_especialidade}.

That way, you won’t need any subreports and you’ll have all the data available to display in the group header and also on the side.

  • 1

    But in this case instead of passing the list, would you pass SQL to ireport to execute? If I pass, I will have to execute many validations that I left in charge of java to do.

  • @adelmo00 Are you using JPA? It’s not clear in your question. In any case, you have two alternatives: switch to SQL or create a single list that contains the data of the 3 entities (repeating the city and the specialty for each provider).

  • I’m not using JPA. The bank administrator gave me the Query that lists the information, run this query by JDBC separate into lists and send to Jasper to mount the report. I’ll do it the way you said by passing the Query straight to Jasper and assembling the groupings in it.

  • @adelmo00 Right, in that case it would be better to pass the query to the report.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.