Skip to content

Commit a68c306

Browse files
committedFeb 28, 2025
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

+1
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

+9-1
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)