Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72388

Datatable jquery only sort day / month and not the full date

$
0
0

I have a table with the following columns:

<thead>
                <tr>
                    <th style="display:none;">ID</th>
                    <th>Nombre Material</th>
                    <th style="width:30%">Nº Parte</th>
                    <th>Aprobado</th>
                    <th>REV</th>
                    <th>Diámetro</th>
                    <th>Largo</th>
                    <th>Top</th>
                    <th>Bottom</th>
                    <th>Otros</th>
                    <th>Dado/Dia</th>
                    <th>Uni/Cajas</th>
                    <th class="rotate"><div><span>Orden Interna</span></div></th>
                    <th class="rotate"><div><span>Plano de Corte</span></div></th>
                    <th class="rotate"><div><span>Plano Marcación</span></div></th>
                    <th class="rotate"><div><span>Instruc. de Trabajo</span></div></th>
                    <th class="rotate"><div><span>Plano Especifica</span></div></th>
                    <th class="rotate"><div><span>Instruc.Sheet Cliente</span></div></th>
                    <th class="rotate"><div><span>Drawing Cliente</span></div></th>
                    <th>Última orden emitida</th>
                    <th>Cliente Final</th>
                    <th>Editar Datos</th>
                </tr>
            </thead>

I'm organizing the table using rowGroup to put all rows in a similar set (each with its family), the code I use for that is this:

//SE INICIALIZA LA TABLA
    $('.tablaPulse').DataTable({
        "aoColumns": [
            null,
            null,
            null,
            { "sType": "date" },
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            { "sType": "date" },
            null,
            null
        ],
        "columnDefs": [
            { "visible": false, "targets": 1 },
            {
                "targets": 3,
                //type: 'datetime-moment'"render": $.fn.dataTable.moment('YYYY/MM/DD', 'DD/MM/YYYY')
            }
        ],
        //order: [[1, 'asc']],
        rowGroup: {
            startRender: function (rows, group) {
                return $('<tr/>')
                    .append('<td  class="numPul" bgcolor="#78923B">' + group + '</td>')
                    .append('<td  class="numPul" bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>')
                    .append('<td  bgcolor="#78923B"></td>');
            },
            endRender: null,
            dataSrc: 1
        }
    });

The table looks as follows:

enter image description here

When I try to sort everything by date, he orders me everything by day/month and not on his date, for example, in this case he orders me the dates from 31 down and skips the years:

enter image description here

The code where I initialized the table was smaller, I was adding several examples of code that I saw on the internet and they don't work for me, the parts of code I added were:

"aoColumns": [
        null,
        null,
        null,
        { "sType": "date" },
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        { "sType": "date" },
        null,
        null
    ],

and...

{      "targets": 3,
        //type: 'datetime-moment'"render": $.fn.dataTable.moment('YYYY/MM/DD', 'DD/MM/YYYY')
}

and still nothing works, what can I modify or add so that I can order the dates as it should?

PD: I already added moment.js


Viewing all articles
Browse latest Browse all 72388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>