feat: enale temporary sorting on table panel type (#5114)

This commit is contained in:
Vikrant Gupta 2024-05-31 13:52:07 +05:30 committed by GitHub
parent 6aded04b7f
commit 0760917a4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,7 @@ import {
import { FORMULA_REGEXP } from 'constants/regExp';
import { QUERY_TABLE_CONFIG } from 'container/QueryTable/config';
import { QueryTableProps } from 'container/QueryTable/QueryTable.intefaces';
import { isEqual, isObject } from 'lodash-es';
import { isEqual, isNaN, isObject } from 'lodash-es';
import { ReactNode } from 'react';
import {
IBuilderFormula,
@ -460,6 +460,18 @@ const generateTableColumns = (
title: item.title,
width: QUERY_TABLE_CONFIG.width,
render: renderColumnCell && renderColumnCell[item.dataIndex],
sorter: (a: RowData, b: RowData): number => {
const valueA = Number(a[item.dataIndex]);
const valueB = Number(b[item.dataIndex]);
if (!isNaN(valueA) && !isNaN(valueB)) {
return valueA - valueB;
}
return ((a[item.dataIndex] as string) || '').localeCompare(
(b[item.dataIndex] as string) || '',
);
},
};
return [...acc, column];