This repository was archived by the owner on Jul 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed
Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,14 @@ import Select, { OnChangeValue } from "react-select";
4141import TableRow from "components/TableRow" ;
4242import getInitialColumnSizing from "components/behavior/InitialColumnSizeRecord" ;
4343import { globalDatabaseFilterFn } from "components/reducers/TableFilterFlavours" ;
44+ import dbfolderColumnSortingFn from "./reducers/CustomSortingFn" ;
4445
4546const defaultColumn : Partial < ColumnDef < RowDataType > > = {
4647 minSize : DatabaseLimits . MIN_COLUMN_HEIGHT ,
4748 maxSize : DatabaseLimits . MAX_COLUMN_HEIGHT ,
4849 cell : DefaultCell ,
4950 header : DefaultHeader ,
5051 enableResizing : true ,
51- sortingFn : "auto" ,
5252} ;
5353
5454/**
@@ -242,7 +242,10 @@ export function Table(tableData: TableDataType) {
242242 tableState : tableStore ,
243243 view : view ,
244244 } ,
245- defaultColumn : defaultColumn ,
245+ defaultColumn : {
246+ ...defaultColumn ,
247+ sortingFn : dbfolderColumnSortingFn ( configInfo . getLocalSettings ( ) ) ,
248+ } ,
246249 getExpandedRowModel : getExpandedRowModel ( ) ,
247250 getCoreRowModel : getCoreRowModel ( ) ,
248251 getSortedRowModel : getSortedRowModel ( ) ,
Original file line number Diff line number Diff line change 1+ import { Row , SortingFn } from "@tanstack/react-table" ;
2+ import { RowDataType } from "cdm/FolderModel" ;
3+ import { LocalSettings } from "cdm/SettingsModel" ;
4+ import { InputType } from "helpers/Constants" ;
5+ import { Literal } from "obsidian-dataview" ;
6+ import { DataviewService } from "services/DataviewService" ;
7+
8+ const dbfolderColumnSortingFn : (
9+ ddbbConfig : LocalSettings
10+ ) => SortingFn < RowDataType > =
11+ ( ddbbConfig : LocalSettings ) =>
12+ (
13+ rowA : Row < RowDataType > ,
14+ rowB : Row < RowDataType > ,
15+ columnId : string
16+ ) : number => {
17+ const a = DataviewService . parseLiteral (
18+ rowA . getValue < Literal > ( columnId ) ,
19+ InputType . MARKDOWN ,
20+ ddbbConfig ,
21+ true
22+ )
23+ . toString ( )
24+ . toLowerCase ( ) ;
25+ const b = DataviewService . parseLiteral (
26+ rowB . getValue < Literal > ( columnId ) ,
27+ InputType . MARKDOWN ,
28+ ddbbConfig ,
29+ true
30+ )
31+ . toString ( )
32+ . toLowerCase ( ) ;
33+ return a === b ? 0 : a > b ? 1 : - 1 ;
34+ } ;
35+
36+ export default dbfolderColumnSortingFn ;
You can’t perform that action at this time.
0 commit comments