DataTable group Column

DataTable group Column

gvillelagvillela Posts: 4Questions: 1Answers: 0
edited February 2019 in Free community support

Gentlemen,
I'm trying to group a date column, it works, but when the range of dates is longer than two months gets confusing, DataTables can not sort correctly.
I'm trying like this:

Date: 01/01/2019 ---- 01/03/2019

stays like this:

01/01/2019
02/01/2019
02/02/2019
03/01/2019
03/02/2019
...

Can someone help me? Thank you

 "order": [[ groupColumn, 'asc' ]],
        //"responsive": true,
        "displayLength": 25,
        "drawCallback": function ( settings ) {
            var api = this.api();
            var rows = api.rows({ page: 'current' }).nodes();
            var last=null;
 
            api.column(groupColumn, { page:'current' } ).data().each( function ( group, i ) {
                if ( last !== group ) {
                    $(rows).eq( i ).before(
                        '<tr class="group"><td colspan="15" style="font-family:Arial, Helvetica, sans-serif; font-size: 130%; font-weight:bold;">'+group+'</td></tr>'
                    );
 
                    last = group;
                }
            } );
        }

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @gvillela ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • gvillelagvillela Posts: 4Questions: 1Answers: 0
    edited February 2019

    Sorry and sorry my english i know it's bad. :-)

    https://jsfiddle.net/gvillela/h52fLs9a/10/

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @gvillela ,

    Is this here working how you'd expect? You'll notice I explicitly state the date format so that the ordering knows what to do,

    Cheers,

    Colin

  • gvillelagvillela Posts: 4Questions: 1Answers: 0

    Hi @colin ,
    Thank you so much, you solved issue.

This discussion has been closed.