fix: footer(합계) 작업 중
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import type { GridView, DataColumn } from "@/components/type/DataGrid.type";
|
||||
|
||||
export const getFooterSummary = (grid: GridView, column: DataColumn) => {
|
||||
// 데이터 소스에서 직접 합계 계산
|
||||
const dataSource = grid.getDataSource();
|
||||
const rowCount = dataSource.getRowCount();
|
||||
let sum = 0;
|
||||
|
||||
for (let i = 0; i < rowCount; i++) {
|
||||
const cellValue = dataSource.getValue(i, column.fieldName);
|
||||
// 문자열인 경우 숫자로 변환
|
||||
const numericValue = typeof cellValue === 'string'
|
||||
? Number(String(cellValue).replace(/,/g, ''))
|
||||
: Number(cellValue);
|
||||
|
||||
if (!isNaN(numericValue) && numericValue !== null && numericValue !== undefined) {
|
||||
sum += numericValue;
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
};
|
||||
Reference in New Issue
Block a user