Skip to content

w2grid: sortMode callback is called too late #2653

@pfalcon

Description

@pfalcon

I wanted my cells to show one value in the grid, and show another value as a tooltip. Granted, the most obvious way to achieve that is to set cell's data as [value, tooltip], then have renderer and title callbacks to unpack needed value. Worked well, but broke sorting on this column (value is numeric). This is of course because JS cannot compare array with </> operators normally and coerce them to strings. But even after I defined sortMode callback for the column, the sort didn't work properly. So, looking at compareCells implementation https://github.com/vitmalina/w2ui/blob/master/src/w2grid.js#L977 , I would suggest that sortMode callback is called too late in this function.

The idea should be simple: as long as user has defined this callback, they expect it to take sorting decisions, so it should be called as soon as possible in this function. Actually, I'd suggest that it should be called before handling null values in there, because what if user doesn't agree with "all nulls, empty and undefined on bottom" and wants a different behavior? Why preclude them from achieving it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions