Skip to content

Quick and Dirty Solution to sort by Date #31

Description

@pepperbilly

Hello
I Find a quick and Dirty Solution to sort the Table by Date:

1 Safe your Date in a Sortable Format (for example unix Timestamp or what Ever)
in my Case i used the following format: YYYY-MM-DD wich is as well sortable as an integer.

2 Call A Renderfunction for the Date Column
renderfunction: DateRenderFunction

3 Build Your Renderfunction

var DateRenderFunction = function (colname, entry){
        var res = entry['datum'].split("-");
        var newDate = res[2]+'.'+res[1]+'.'+res[0];

        //HERE IS THE TRICK:
        //patch the Original (YYYY-MM-DD sortable) Date in front of the New (DD.MM.YY)
        //and Wrap it with a <p> tag which is invisible by adding display:none
        //it will be read by the sort function even though it is invisible for the html


        var patchDate = '<p style="visibility:hidden;display:none">'+entry['datum']+'</p>'+ newDate;
        return patchDate;
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions