-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How is the best way to sum a column of a listbox and put the result in a footer?
Thanks
Manuel Guil
Whats problem in that?
Get the items list using List.getItems().
Then access the individual list items and do your sum calculation as per your requirement.
For a few days i have work on my todo list and implement the outstanding ListFooter for summarizing a column field.
In my case i fill the ListFooter by a methode that made the summarizing with hibernate code in my DB-backend
because my listboxes are paging the data. Now the Listfooter shows all times the result of all affected records
independent of the listboxes page.
best
Stephan
Baskaraninfo: Thanks for your answer, now i'm using List.getItems(), but I don´t like this way, when you change the list items the Listfooter doesn't refresh automaticaly...
Stephan: Your solutions sounds very good. Could you put a example of your summarizing methode.
Manuel
[email protected]
It's Spring-managed Hibernate.
/** * Gets the sum for all 'aupGesamtwert' fields of the table orderPositions * for an order (auftrag).<br> * * (non-Javadoc) * * @see de.daibutsu.backend.dao.AuftragDAO#getAuftragSumme(de.daibutsu.backend.model.Auftrag) */ @Override public BigDecimal getAuftragSumme(Auftrag auftrag) { DetachedCriteria criteria = DetachedCriteria.forClass(Auftragposition.class); criteria.add(Restrictions.eq("auftrag", auftrag)); ProjectionList proList = Projections.projectionList(); proList.add(Projections.sum("aupGesamtwert")); criteria.setProjection(proList); BigDecimal sumResult = (BigDecimal) DataAccessUtils.uniqueResult(getHibernateTemplate() .findByCriteria(criteria)); return sumResult; }
best
Stephan
Asked: 2009-11-11 16:37:41 +0800
Seen: 864 times
Last updated: Nov 14 '09