ui: fix table column export

This commit is contained in:
nick-delirium 2025-03-20 16:06:44 +01:00
parent 91e0ebeb56
commit fa3b585785
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 5 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import { useTranslation } from 'react-i18next';
const initTableProps = [
{
title: <span className="font-medium">Series</span>,
_pureTitle: 'Series',
dataIndex: 'seriesName',
key: 'seriesName',
sorter: (a, b) => a.seriesName.localeCompare(b.seriesName),
@ -18,6 +19,7 @@ const initTableProps = [
},
{
title: <span className="font-medium">Avg.</span>,
_pureTitle: 'Avg.',
dataIndex: 'average',
key: 'average',
sorter: (a, b) => a.average - b.average,
@ -94,6 +96,8 @@ function WidgetDatatable(props: Props) {
tableCols.push({
title: <span className="font-medium">{name}</span>,
dataIndex: `${name}_${i}`,
// @ts-ignore
_pureTitle: name,
key: `${name}_${i}`,
sorter: (a, b) => a[`${name}_${i}`] - b[`${name}_${i}`],
});

View file

@ -597,8 +597,7 @@ function saveAsFile(blob: Blob, filename: string) {
}
export function exportAntCsv(tableColumns, tableData, filename = 'table.csv') {
console.log(tableColumns, tableData);
const headers = tableColumns.map((col) => col.title).join(',');
const headers = tableColumns.map((col) => col._pureTitle).join(',');
const rows = tableData.map((row) =>
tableColumns
.map((col) => {