Hi,
I am wondering how I can sort a AG Dash Grid by the absolute value of certain columns? So, let’s say I have 5 numeric columns. When the user clicks on the sort button, I would like three of the five columns to be sorted by absolute value, the other two should still be sorted normally. Many thanks.
I figured this out. In case it is helpful to someone else
var dagfuncs = window.dashAgGridFunctions = window.dashAgGridFunctions || {};
dagfuncs.absoluteComparator = function (num1, num2) {
if (num1 === null && num2 === null) {
return 0;
}
if (num1 === null) {
return -1;
}
if (num2 === null) {
return 1;
}
return Math.abs(num1) - Math.abs(num2);
}
3 Likes