calculateSummaryValue method
String
calculateSummaryValue(
- GridTableSummaryRow summaryRow,
- GridSummaryColumn? summaryColumn,
- RowColumnIndex rowColumnIndex
Calculates the summary value for the table summary row of a specific column.
Override this method to write the custom logic to calculate the custom summary.
The summaryColumn
will be null for the spanned table summary columns.
Implementation
String calculateSummaryValue(GridTableSummaryRow summaryRow,
GridSummaryColumn? summaryColumn, RowColumnIndex rowColumnIndex) {
final int titleColumnSpan = grid_helper.getSummaryTitleColumnSpan(
_dataGridStateDetails!(), summaryRow);
if (summaryRow.showSummaryInRow ||
(!summaryRow.showSummaryInRow &&
titleColumnSpan > 0 &&
rowColumnIndex.columnIndex < titleColumnSpan)) {
String title = summaryRow.title ?? '';
if (summaryRow.title != null) {
for (final GridSummaryColumn cell in summaryRow.columns) {
if (title.contains(cell.name)) {
final String summaryValue =
grid_helper.getSummaryValue(cell, _effectiveRows);
title = title.replaceAll('{${cell.name}}', summaryValue);
}
}
}
return title;
} else {
return grid_helper.getSummaryValue(summaryColumn!, _effectiveRows);
}
}