Good afternoon,
For the creation of a report I make two searches, one in each distinct table. After, I create a list only with the data returned from those two. Example:
List<Venda> lista = new ArrayList<Venda>();
Collection<Produto> lProduto = dao.listaProduto();
for(Produto p: lProduto) {
Venda v = new Venda();
v.setVendedor(p.getVendedor);
v.setvalor(p.getValorvenda);
lista.add(v);
}
Collection<Servico> lServico = dao.listaServico();
for(Servico s: lServico) {
Venda v = new Venda();
v.setVendedor(s.getVendedor);
v.setvalor(s.getValorvenda);
lista.add(v);
}
Ok, I step to the iReport list. It is set up in your group expression for the seller:
<field name="vendedor" class="minha.app.teste.Vendedor"/>
<groupExpression><![CDATA[$F{vendedor}]]></groupExpression>
With groupHeader:
<textFieldExpression><![CDATA[$F{vendedor}.getNome()]]></textFieldExpression>
But in the view, this grouping is not done. Alias, it groups, but separating same product service being the same vendor. Ex.:
Vendedor 01
Produto Teste 01 | 25,00
Produto Teste 02 | 20,00
Vendedor 01
Serviço Teste 01 | 45,00
Test Service 01 should be in the group above.
The two methods that search the list are ordered by the seller. I have already tried to do a Collections.sort (list), using as a comparison the seller that is inside the list, but it did not work either. = /
Could someone please help me?