Commit 5f767e2c by Speak Your Code Committed by GitHub

TablePanel: Sort numbers correctly (#25421)

* Table sortType to basic to be able to sort negative numbers

* Table sortType based on field type
parent 70038bfd
......@@ -35,7 +35,7 @@ export function getTextAlign(field?: Field): TextAlignProperty {
}
export function getColumns(data: DataFrame, availableWidth: number, columnMinWidth: number): Column[] {
const columns: Column[] = [];
const columns: any[] = [];
let fieldCountWithoutWidth = data.fields.length;
for (const [fieldIndex, field] of data.fields.entries()) {
......@@ -50,6 +50,15 @@ export function getColumns(data: DataFrame, availableWidth: number, columnMinWid
fieldCountWithoutWidth -= 1;
}
const selectSortType = (type: FieldType): string => {
switch (type) {
case FieldType.number:
case FieldType.time:
return 'basic';
default:
return 'alphanumeric';
}
};
const Cell = getCellComponent(fieldTableOptions.displayMode, field);
columns.push({
Cell,
......@@ -58,6 +67,7 @@ export function getColumns(data: DataFrame, availableWidth: number, columnMinWid
accessor: (row: any, i: number) => {
return field.values.get(i);
},
sortType: selectSortType(field.type),
width: fieldTableOptions.width,
minWidth: 50,
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment