I get invalid date retrieving data from first cell
I get invalid date retrieving data from first cell
itajackass
Posts: 162Questions: 48Answers: 3
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
This discussion has been closed.
Answers
The data is being read in as an object if you use that structure for
columns.data
. If you usedata[0].display
you would get the data data. Usedata[0]['@data-order']
if you want the ordering data.Allan
Thank you!