String columnName = "Duration";
BigDecimal somme = Env.ZERO;
int idx = 0;
for (int i = 0; i < contentPanel.getColumnCount(); i++) { // Recherche du numéro de la colonne
if (p_layout[i].getGridField() != null && p_layout[i].getGridField().getColumnName().equals(columnName))
idx = i;
}
for (int rowIndex = 0; rowIndex < contentPanel.getModel().getRowCount(); rowIndex++){
Integer keyCandidate = getColumnValue(rowIndex);
@SuppressWarnings("unchecked")
List<Object> candidateRecord = (List<Object>)contentPanel.getModel().get(rowIndex);
if (contentPanel.getModel().isSelected(candidateRecord)) {
if (!recordSelectedData.containsKey(keyCandidate))
somme = somme.add((BigDecimal) contentPanel.getValueAt(rowIndex, idx));
}
}
for (Component h : contentPanel.getHeads())
((ListHeader) h.getChildren().get(idx)).setLabel("TOTAL " + somme);
And then this will be the result:
Or as an alternative (controlled with a sysconfig key):