mirror of https://github.com/grafana/grafana.git
				
				
				
			TablePanel: Makes sorting case-insensitive (#32435)
* UI/Table: Make sorting case-insensitive Closes #30476
This commit is contained in:
		
							parent
							
								
									acc8e78c24
								
							
						
					
					
						commit
						6c16ecf65f
					
				|  | @ -14,7 +14,7 @@ import { | |||
|   useTable, | ||||
| } from 'react-table'; | ||||
| import { FixedSizeList } from 'react-window'; | ||||
| import { getColumns } from './utils'; | ||||
| import { getColumns, sortCaseInsensitive } from './utils'; | ||||
| import { useTheme } from '../../themes'; | ||||
| import { | ||||
|   TableColumnResizeActionCallback, | ||||
|  | @ -151,6 +151,9 @@ export const Table: FC<Props> = memo((props: Props) => { | |||
|       disableResizing: !resizable, | ||||
|       stateReducer: stateReducer, | ||||
|       initialState: getInitialState(initialSortBy, memoizedColumns), | ||||
|       sortTypes: { | ||||
|         'alphanumeric-insensitive': sortCaseInsensitive, | ||||
|       }, | ||||
|     }), | ||||
|     [initialSortBy, memoizedColumns, memoizedData, resizable, stateReducer] | ||||
|   ); | ||||
|  |  | |||
|  | @ -63,7 +63,7 @@ export function getColumns(data: DataFrame, availableWidth: number, columnMinWid | |||
|         case FieldType.time: | ||||
|           return 'basic'; | ||||
|         default: | ||||
|           return 'alphanumeric'; | ||||
|           return 'alphanumeric-insensitive'; | ||||
|       } | ||||
|     }; | ||||
| 
 | ||||
|  | @ -204,3 +204,7 @@ export function getFilteredOptions(options: SelectableValue[], filterValues?: Se | |||
| 
 | ||||
|   return options.filter((option) => filterValues.some((filtered) => filtered.value === option.value)); | ||||
| } | ||||
| 
 | ||||
| export function sortCaseInsensitive(a: Row<any>, b: Row<any>, id: string) { | ||||
|   return String(a.values[id]).localeCompare(String(b.values[id]), undefined, { sensitivity: 'base' }); | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue