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

Quick and Dirty Solution to sort by Date #31

Open
pepperbilly opened this issue Jul 23, 2020 · 0 comments
Open

Quick and Dirty Solution to sort by Date #31

pepperbilly opened this issue Jul 23, 2020 · 0 comments

Comments

@pepperbilly
Copy link

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;
    };
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

1 participant