Group at Ireport (Jasperstudio)

Asked

Viewed 83 times

1

Good afternoon,

To create a report I do two searches, one in each separate table. After, I create a list only with the data returned from these 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, step to iReport the list. It is configured in your Expression group for the seller:

<field name="vendedor" class="minha.app.teste.Vendedor"/>
<groupExpression><![CDATA[$F{vendedor}]]></groupExpression>

With the groupHeader:

<textFieldExpression><![CDATA[$F{vendedor}.getNome()]]></textFieldExpression>

But in the exhibition, there is no such grouping. Alias, it groups but separating product service even being the same seller. 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 top cluster.

The two methods that search for the list have order by the seller. I already tried to make a Collections.Sort(list), using as a comparison the seller that is within the list, but it didn’t work either. =/

Please, could someone help me?

No answers

Browser other questions tagged

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