ui: fix table column export
This commit is contained in:
parent
91e0ebeb56
commit
fa3b585785
2 changed files with 5 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import { useTranslation } from 'react-i18next';
|
||||||
const initTableProps = [
|
const initTableProps = [
|
||||||
{
|
{
|
||||||
title: <span className="font-medium">Series</span>,
|
title: <span className="font-medium">Series</span>,
|
||||||
|
_pureTitle: 'Series',
|
||||||
dataIndex: 'seriesName',
|
dataIndex: 'seriesName',
|
||||||
key: 'seriesName',
|
key: 'seriesName',
|
||||||
sorter: (a, b) => a.seriesName.localeCompare(b.seriesName),
|
sorter: (a, b) => a.seriesName.localeCompare(b.seriesName),
|
||||||
|
|
@ -18,6 +19,7 @@ const initTableProps = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: <span className="font-medium">Avg.</span>,
|
title: <span className="font-medium">Avg.</span>,
|
||||||
|
_pureTitle: 'Avg.',
|
||||||
dataIndex: 'average',
|
dataIndex: 'average',
|
||||||
key: 'average',
|
key: 'average',
|
||||||
sorter: (a, b) => a.average - b.average,
|
sorter: (a, b) => a.average - b.average,
|
||||||
|
|
@ -94,6 +96,8 @@ function WidgetDatatable(props: Props) {
|
||||||
tableCols.push({
|
tableCols.push({
|
||||||
title: <span className="font-medium">{name}</span>,
|
title: <span className="font-medium">{name}</span>,
|
||||||
dataIndex: `${name}_${i}`,
|
dataIndex: `${name}_${i}`,
|
||||||
|
// @ts-ignore
|
||||||
|
_pureTitle: name,
|
||||||
key: `${name}_${i}`,
|
key: `${name}_${i}`,
|
||||||
sorter: (a, b) => a[`${name}_${i}`] - b[`${name}_${i}`],
|
sorter: (a, b) => a[`${name}_${i}`] - b[`${name}_${i}`],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -597,8 +597,7 @@ function saveAsFile(blob: Blob, filename: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exportAntCsv(tableColumns, tableData, filename = 'table.csv') {
|
export function exportAntCsv(tableColumns, tableData, filename = 'table.csv') {
|
||||||
console.log(tableColumns, tableData);
|
const headers = tableColumns.map((col) => col._pureTitle).join(',');
|
||||||
const headers = tableColumns.map((col) => col.title).join(',');
|
|
||||||
const rows = tableData.map((row) =>
|
const rows = tableData.map((row) =>
|
||||||
tableColumns
|
tableColumns
|
||||||
.map((col) => {
|
.map((col) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue