cellRenderer ; , , . , , , columnDef :
var columnDefs = [
{headerName: "Athlete", field: "athlete", width: 150, sort: 'desc'},
...
];
Def:
{headerName: "Athlete", field: "athlete", width: 150, sort: 'desc',
comparator: function(valueA, valueB, nodeA, nodeB, isInverted)
{return caseInsensitiveSort(valueA, valueB, nodeA, nodeB, isInverted);}
}
.
function caseInsensitiveSort(valueA, valueB, nodeA, nodeB, isInverted) {
return valueA.toLowerCase().localeCompare(valueB.toLowerCase());
}
, isInverted, , , ag-grid.
, isInverted, , , . , , :
function caseInsensitiveSort(valueA, valueB, nodeA, nodeB, isInverted) {
if( valueA === "" || valueA === null ) {
if( valueB === "" || valueB === null ) {
return 0; // a and b are both blank; 0 means identical
} else {
return (isInverted ? -1 : 1); // a is null, b is not; return 1 for normal sort or -1 for inverted
}
}
if( valueB === "" || valueB === null ) {
return (isInverted ? 1 : -1); // b is null, a is not; return -1 for normal or 1 for inverted to get the opposite result as above
}
return valueA.toLowerCase().localeCompare(valueB.toLowerCase());
};
, columnDef; , .
var columnDefs = [
{headerName: "Athlete", field: "athlete", width: 150, sort: 'desc', type: 'text'},
...
];
var gridOptions = {
columnDefs: columnDefs,
...
columnTypes: {
"text": {comparator: function(valueA, valueB, nodeA, nodeB, isInverted)
{return caseInsensitiveSort(valueA, valueB, nodeA, nodeB, isInverted);}
}
};
, ; , plunkr, , . ag-grid , , , , , , , , , .