I am working in some grids and I notice that the sorting on all of them is key sensitive is there any way to change that. This is a part of my code.
columnD
This can be done by using a custom sorting function on the particular column that requires case-insensitive sorting.
For instance, for your columnDefs
, if you require the name
column to be sorted case insentitve, we pass the customComparator
as the value for the comparator
property. In your ngOnInit,
this.columnDefs = [
{
headerName: 'Name',
field: 'name',
sort: 'asc', // optional, allows grid column to be sorted on init
comparator: customComparator
},
// other columns
];
Then, we define the customComparator such that it carries out case-insentitive sorting. We do so by converting the values to lowercase on the custom comparator.
const customComparator = (valueA, valueB) => {
return valueA.toLowerCase().localeCompare(valueB.toLowerCase());
};
EDIT: I have forked and recreated a demo from the original ag-grid demo to demonstrate the usage of the above comparator. Refer to the constructor() method for the relevant details.
Update for 2020-07, agTextColumnFilter
that is the default ag-Grid filter, accepts parameters. One of which is caseSensitive
.
See sample