Pass updated information from subreport to parent report

1

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

In ireport stayed 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 needs that each page has the name of the city and on the side the name of the specialty. Passing information from the subreport to the main report I get through a variable, I just can not put it 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 name of the specialty on the same side of the name of the city.

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

    
asked by anonymous 11.02.2014 / 12:45

1 answer

1

I do not think you need to create a three-level report. You can solve this by creating a query that joins the three tables and creates two groups, one for town and one for specialty.

As I do not know your model, I'll 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, you just have to create groups in iReport (not in the query), namely a group with the value of $F{nome_cidade} and another with $P{titulo_especialidade} .

In this way, you will not need any subreports and will have all the data available to display in the group header and also on the side.

    
11.02.2014 / 13:04