mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 20:35:57 +08:00
fix: table sorting when units are present (#5249)
This commit is contained in:
parent
f1b5da9916
commit
2a4e97f8da
@ -62,10 +62,11 @@ function GridTableComponent({
|
||||
|
||||
mutateDataSource = mutateDataSource.map(
|
||||
(val): RowData => {
|
||||
const newValue = val;
|
||||
const newValue = { ...val };
|
||||
Object.keys(val).forEach((k) => {
|
||||
if (columnUnits[k]) {
|
||||
newValue[k] = getYAxisFormattedValue(String(val[k]), columnUnits[k]);
|
||||
newValue[`${k}_without_unit`] = val[k];
|
||||
}
|
||||
});
|
||||
return newValue;
|
||||
@ -81,7 +82,6 @@ function GridTableComponent({
|
||||
applyColumnUnits,
|
||||
originalDataSource,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (tableProcessedDataRef) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
@ -537,8 +537,12 @@ const generateTableColumns = (
|
||||
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]);
|
||||
const valueA = Number(
|
||||
a[`${item.dataIndex}_without_unit`] ?? a[item.dataIndex],
|
||||
);
|
||||
const valueB = Number(
|
||||
b[`${item.dataIndex}_without_unit`] ?? b[item.dataIndex],
|
||||
);
|
||||
|
||||
if (!isNaN(valueA) && !isNaN(valueB)) {
|
||||
return valueA - valueB;
|
||||
|
Loading…
x
Reference in New Issue
Block a user