Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Calculated and summary column (ListGrid)

    Hi everybody,

    I have a listgrid with a calculated and summary column, the calculated value is showed correctly but the summary doesn't work. Can anybody give me some help ?

    This is the code for the column:

    ListGridField importeField = new ListGridField("importe", "Importe");
    importeField.setType(ListGridFieldType.FLOAT);
    importeField.setShowGridSummary(true);
    importeField.setCanEdit(false);


    importeField.setCellFormatter(new CellFormatter() {
    public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
    if(record != null){
    Double importe = new Double(ConvertUtil.convertIsNumberNull(record.getAttribute("valorunitario"))) * new Double(ConvertUtil.convertIsNumberNull(record.getAttribute("cantidad")));
    NumberFormat nf = NumberFormat.getFormat("#,##0.00");

    record.setAttribute("importe",importe);
    return "$" + nf.format(((Number) importe).doubleValue());
    } else {
    NumberFormat nf = NumberFormat.getFormat("#,##0.00");
    return "$" + nf.format(((Number) 0).doubleValue());
    }
    }
    });
Working...
X