HorizontalAlignment[] horizontalAlignments = { HorizontalAlignment.CENTER };
AggregationRowConfig<TransfertPpSummaryDto> totalSummary = new AggregationRowConfig<TransfertPpSummaryDto>();
totalSummary.setHtml(TransfertPpSummaryDto.LABEL, "Total PP".toUpperCase());
ColumnModel cm = createColumnModel(headers, ids, columnsWidth, horizontalAlignments);
transfertPpGrid = new CustomEditorGrid(new ListStore<TransfertPpSummaryDto>(), cm);
transfertPpGrid.getView().setAutoFill(true);
List<String> summaryColumns = Arrays.asList(
TransfertPpSummaryDto.OBJECTIVE, TransfertPpSummaryDto.OBJ, TransfertPpSummaryDto.DEVERS,
TransfertPpSummaryDto.RD, TransfertPpSummaryDto.TS, TransfertPpSummaryDto.TOTAL);
for( String columnId : summaryColumns ) {
ColumnConfig column = cm.getColumnById(columnId);
column.setNumberFormat(NumberFormat.getFormat(NUMBER_FORMAT));
totalSummary.setSummaryType(columnId, SummaryType.SUM);
totalSummary.setSummaryFormat(columnId, NumberFormat.getCurrencyFormat());
}
cm.addAggregationRow(totalSummary);
cm.getColumnById(TransfertPpSummaryDto.ID).setRenderer(new GridCellRenderer<TransfertPpSummaryDto>() {
@Override
public Object render(final TransfertPpSummaryDto model, String property,
com.extjs.gxt.ui.client.widget.grid.ColumnData config, int rowIndex, int colIndex,
ListStore<TransfertPpSummaryDto> store, Grid<TransfertPpSummaryDto> grid) {
Image viewButton = createViewButton();
viewButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// bus.fireEvent(new LoadTransfertppSummaryDtoEvent(model));
GuiUtil.gotoEcran(new TransfertppEcran(chantier, model.getRefTransfertPpId(), role, user));
}
});
return viewButton;
}
});
ColumnConfig objectiveColumn = cm.getColumnById(TransfertPpSummaryDto.OBJECTIVE);
objectiveColumn.setRenderer(createNumberRendererWithPermission(objectiveColumn.getWidth() - PADDING, role, user));
objectiveColumn.setEditor(new CellEditor(createLockNumberFieldWithPermission(null, role, user)));
transfertPpGrid.setAutoHeight(true);
loadTransfertPpData();
}