I get invalid date retrieving data from first cell

I get invalid date retrieving data from first cell

itajackassitajackass Posts: 162Questions: 48Answers: 3
edited January 2018 in Free community support

I've this callback but i get always invalid date cause data[0] is Object object:

         "createdRow": function( row, data, dataIndex ) {

        var today = moment().format('YYYY-MM-DD');
        var scadenza = moment(data[0], "DD/MM/YYYY").format("YYYY-MM-DD"); // from italian format

        alert(scadenza); // i get invalid date

        if ( scadenza.isBefore(today) ) {
            $(row).addClass( 'bg-primary' );
        }

    },"columnDefs": [
        {
            targets: [0],
            data: {
                _: "0.display",
                sort: "0.@data-order",
                type: "0.@data-order"
            }
        }
    ]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    The data is being read in as an object if you use that structure for columns.data. If you use data[0].display you would get the data data. Use data[0]['@data-order'] if you want the ordering data.

    Allan

  • itajackassitajackass Posts: 162Questions: 48Answers: 3

    Thank you!

This discussion has been closed.