Skip to content

Commit a68c306

Browse files
fixed sorting issue in table's data/datetime columns
1 parent 10fbb2f commit a68c306

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

client/packages/lowcoder/src/comps/comps/tableComp/column/tableColumnComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export class ColumnComp extends ColumnInitComp {
219219
const columnType = this.children.render.getSelectedComp().getComp().children.compType.getView();
220220
return {
221221
...superView,
222+
columnType,
222223
editable: ColumnTypeCompMap[columnType].canBeEditable() && superView.editable,
223224
};
224225
}

client/packages/lowcoder/src/comps/comps/tableComp/tableUtils.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { TableColumnLinkStyleType, TableColumnStyleType } from "comps/controls/s
2121
import Tooltip from "antd/es/tooltip";
2222
import InfoCircleOutlined from "@ant-design/icons/InfoCircleOutlined";
2323
import { EMPTY_ROW_KEY } from "./tableCompView";
24+
import dayjs from "dayjs";
2425

2526
export const COLUMN_CHILDREN_KEY = "children";
2627
export const OB_ROW_ORI_INDEX = "__ob_origin_index";
@@ -399,7 +400,14 @@ export function columnsToAntdFormat(
399400
},
400401
...(column.sortable
401402
? {
402-
sorter: { multiple: (sortedColumns.length - mIndex) + 1 },
403+
sorter: {
404+
multiple: (sortedColumns.length - mIndex) + 1,
405+
compare: column.columnType === 'date' || column.columnType === 'dateTime'
406+
? (a,b) => {
407+
return dayjs(a[column.dataIndex] as string).unix() - dayjs(b[column.dataIndex] as string).unix();
408+
}
409+
: undefined
410+
},
403411
sortOrder: sortMap.get(column.dataIndex),
404412
showSorterTooltip: false,
405413
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy