Created
January 20, 2021 16:07
-
-
Save YonathanMeguira/86e3474a1fdeb9dfedbc4a8d324fe023 to your computer and use it in GitHub Desktop.
AG-grid: sorting for custom rendered colums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myColDefs = [{ | |
headerName: 'Header Name', | |
sortable: true, | |
cellRenderer: 'propName', | |
comparator: (valueA: any, valueB: any, nodeA: RowNode, nodeB: RowNode, isInverted: boolean) => | |
sortColumnAlphabetically<User>('status', nodeA, nodeB) | |
}] | |
export function sortColumnAlphabetically<T>(key: keyof T, nodeA: any, nodeB: any): number { | |
const [valueA, valueB] = [nodeA.data[key], nodeB.data[key]]; | |
return valueB.localeCompare(valueA); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment