Griddle icon indicating copy to clipboard operation
Griddle copied to clipboard

Null values not sorting correctly in v0.7.0

Open dlong500 opened this issue 9 years ago • 4 comments

Something changed in the sort logic for v0.7.0 from previous versions that breaks the sorting of null values (at least for external data). If I sort by a field ascending that contains null values, the data comes from the database in the correct order but the Griddle component displays the null values at the end of the results. Likewise, if I sort descending the null values show up at the top. It makes for a very confusing mess when combined with pagination.

For example, lets say I have 10 records with a single column like so:

1
<null>
3
4
<null>
6
7
<null>
9
10

If I show 5 records per page and sort ascending, I get the following order on the first page:

1
3
<null>
<null>
<null>

and on the second page:

4
6
7
9
10

Note that the per page results are correct, but the order of the nulls is wrong. The nulls should be at the top of the first page for an ascending sort.

The reverse happens when sorting descending, where the following shows for the first page:

10
9
7
6
4

and then on the second page:

<null>
<null>
<null>
3
1

None of this was happening before v0.7.0. There was a broken search indicator icon (see #453), but even with v0.6.1 the actual external sort was still working with null values--it just didn't show the up or down arrow.

dlong500 avatar Nov 29 '16 20:11 dlong500

Upon further examination it looks like the changes to fix #453 may be causing the external data to be re-sorted by the internal sort functions which most likely causes the bug I'm seeing. This seems really wrong. If we are using external data there should never be any actual sorting being done within Griddle. Only the info to display the sort field and direction should be tracked, but the data should not go through any sort function.

Unless I'm missing something, the data appears to get sorted in the getDataForRender function regardless of whether it is external data or not. I'm thinking this shouldn't be the case.

dlong500 avatar Nov 29 '16 21:11 dlong500

Any comments on this? I've had several users complain about this. I could try to make a PR, but I'd like someone else to confirm my analysis first.

dlong500 avatar Dec 09 '16 09:12 dlong500

We're having the same issue.

tpianta avatar Feb 14 '17 17:02 tpianta

Any timeline on a fix for this being merged in? I want to use v0.8.1 for the onRowMouseEnter and onRowMouseLeave events but numerical sorting seems to also be broken in v0.8.1 too.

brendanluna avatar Mar 03 '17 18:03 brendanluna