String automatically converted to Date problem

String automatically converted to Date problem

michaelcpmichaelcp Posts: 17Questions: 2Answers: 0

Hi everyone,

Attached is a file showing the contents of a column in a table in a database. The problem that I am having is that when these contents are rendered in a DataTable, the last two are converted to dates, for example the 3.3-2020 becomes 03-03-2020 and the last one 1.1-2020 becomes 01-01-2020. I instead want to be rendered exactly as it is stored in the database. Any suggestions are welcome.

Below is the code that is being used for the datatable initialization, have in mind that columns are the titles being retrieved from the database and griddata are the actual data.

_globalGridObject = $('#tabs-' + gettabscurrent() + " #" + gridTableId).DataTable({
'paging': true,
'lengthChange': true,
'searching': true,
'ordering': true,
'colReorder': true,
'info': true,
"scrollX": false,
language: {
searchPlaceholder: "Search",
search: '<i class="fa fa-search dataTableSearchTextboxClass"></i>',
paginate: {
next: '<i class="fa fa-chevron-right "></i>',
previous: '<i class="fa fa-chevron-left "></i>'
}
},
dom: 'Bfrtip',
buttons: [
'excel', 'pdf'
],
select: {
style: 'single'
},
columnDefs: [
{
targets: [0],
className: "hide_column"
}
],
lengthMenu: [[20, 50, 100, 200, 300, -1], [20, 50, 100, 200, 300, "All"]],
columns: columns,
data: griddata
})

Thank you in advance!

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    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

  • michaelcpmichaelcp Posts: 17Questions: 2Answers: 0

    Dear Colin

    Ok will do.

    Thank you for the brief response.

This discussion has been closed.