Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example slickgrid: sorting doesn't work properly #324

Open
ibayer opened this issue Sep 7, 2016 · 1 comment
Open

Example slickgrid: sorting doesn't work properly #324

ibayer opened this issue Sep 7, 2016 · 1 comment

Comments

@ibayer
Copy link

ibayer commented Sep 7, 2016

Hi,
thanks for this awesome library! I just started playing around with the examples and have the impression that
column sorting doesn't work properly for the slickgrid example.

Sort the fiber(g) column in increasing order works.
bildschirmfoto vom 2016-09-07 10 26 37

Sort the fiber(g) column in decreasing order doesn't work. The selected top data point is clearly not the highes fiber(g) value in the plot.
bildschirmfoto vom 2016-09-07 10 28 27

Any idea what goes wrong?
I would really like to use this example. Any help to fix this would be very welcome.

Thanks

@ibayer ibayer changed the title Example slickgrid: sorting doens't work properly Example slickgrid: sorting doesn't work properly Sep 8, 2016
@jeffhussmann
Copy link

jeffhussmann commented Apr 25, 2017

The results are being sorted as strings, not as numbers. To fix, you could replace the comparer function in the example with

function convert_to_float(x) {
    var converted = parseFloat(x);
    return isNaN(converted) ? x : converted
}

function comparer(a, b) {
    var x = convert_to_float(a[sortcol]), y = convert_to_float(b[sortcol]);
    return (x == y ? 0 : (x > y ? 1 : -1));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants