Skip to content

Commit 861fde2

Browse files
authored
✨ Add new argument for advanced use cases
1 parent 976e603 commit 861fde2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/components/datagrid/data_grid_types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export interface EuiDataGridSchemaDetector {
8585
*/
8686
detector: (value: string) => number;
8787
/**
88-
* A custom comparator function when performing in-memory sorting on this data type, takes `(a: string, b: string, direction: 'asc' | 'desc) => -1 | 0 | 1`
88+
* A custom comparator function when performing in-memory sorting on this data type, takes `(a: string, b: string, direction: 'asc' | 'desc', indexes: {aIndex: number, bIndex: number}) => -1 | 0 | 1`
8989
*/
90-
comparator?: (a: string, b: string, direction: 'asc' | 'desc') => -1 | 0 | 1;
90+
comparator?: (a: string, b: string, direction: 'asc' | 'desc', indexes: {aIndex: number, bIndex: number}) => -1 | 0 | 1;
9191
/**
9292
* The icon used to visually represent this data type. Accepts any `EuiIcon IconType`.
9393
*/

src/components/datagrid/utils/sorting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const useSorting = ({
8080
}
8181
}
8282

83-
const result = comparator(aValue, bValue, column.direction);
83+
const result = comparator(aValue, bValue, column.direction, {aIndex: a.index, bIndex: b.index});
8484
// only return if the columns are unequal, otherwise allow the next sort-by column to run
8585
if (result !== 0) return result;
8686
}

0 commit comments

Comments
 (0)