From df1e693ff1057627f200e1d3cc0e0bf3b4fa78d6 Mon Sep 17 00:00:00 2001 From: Rahman Date: Fri, 19 Jan 2024 14:30:07 +0100 Subject: [PATCH] fix(datagrid-web): revert back to .map() usage --- .../datagrid-web/src/features/export.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/pluggableWidgets/datagrid-web/src/features/export.ts b/packages/pluggableWidgets/datagrid-web/src/features/export.ts index 290459f2d0..d3b5090147 100644 --- a/packages/pluggableWidgets/datagrid-web/src/features/export.ts +++ b/packages/pluggableWidgets/datagrid-web/src/features/export.ts @@ -229,12 +229,9 @@ type ExportDataResult = }; function exportData(data: ObjectItem[], columns: ColumnsType[]): ExportDataResult { - const rows = []; let hasLoadingItem = false; - - for (const item of data) { - const row = []; - for (const column of columns) { + const items = data.map(item => { + return columns.map(column => { let value = ""; if (column.showContentAs === "attribute") { value = column.attribute?.get(item)?.displayValue ?? ""; @@ -250,10 +247,9 @@ function exportData(data: ObjectItem[], columns: ColumnsType[]): ExportDataResul } else { value = "n/a (custom content)"; } - row.push(value); - } - rows.push(row); - } + return value; + }); + }); if (hasLoadingItem) { return { @@ -261,7 +257,7 @@ function exportData(data: ObjectItem[], columns: ColumnsType[]): ExportDataResul }; } - return { status: "ready", message: { type: "data", payload: rows } }; + return { status: "ready", message: { type: "data", payload: items } }; } type CallbackFunction = (msg: Message) => Promise | void;