How to convert datetime format in DataTables ? /Date(1445706000000)/
How to convert datetime format in DataTables ? /Date(1445706000000)/
Watchara
Posts: 30Questions: 5Answers: 1
Here's my code js file
$(document).ready(function () {
$('#datatab tfoot th').each(function () {
$(this).html('<input type="text" />');
});
var oTable = $('#datatab').DataTable({
"serverSide": true,
"ajax": {
"type": "POST",
"url": '/Brand/DataHandler',
"contentType": 'application/json',
'data': function (data) { return data = JSON.stringify(data); }
},
"dom": 'frtiS',
"scrollY": 500,
"scrollX": true,
"scrollCollapse": true,
"scroller": {
loadingIndicator: false
},
"processing": true,
"paging": true,
"deferRender": true,
"columns": [
{ "data": "BrandName" },
{ "data": "CreateBy" },
{ "data": "UpdateBy" },
{ "data": "DateCreate",type: 'date-dd-mmm-yyyy', targets: 0 },
{ "data": "DateUpdate" },
{
data: "BrandID", "bSearchable": false,
bSortable: false,
mRender: function (data, type, full) {
return '<a href="Brand/Edit/' + data + '"" class="openDialog btn btn-default btn-warning" >Edit</a> '
+ '<a href="Brand/Delete/' + data + '"" Class="deleteDialog btn btn-default btn-danger " >Delete</a> '
}
}
],
"order": [0, "asc"]
});
oTable.columns().every(function () {
var that = this;
$('input', this.footer()).on('keyup change', function () {
that
.search(this.value)
.draw();
});
});
});
This discussion has been closed.
Answers
You could try using MomentJS - you'll need to use a renderer. Or, convert it on the server-side before it is being sent to DataTables.
Allan
Thanks a lot
Mr. Allan.
and I try to follow by the example of datatables pattern from url
https://editor.datatables.net/examples/advanced/multiItem.html
but it's not working. no data render on screen.
what's wrong with me?
I'm not sure why it isn't working. Can you give me a link to the page so I can take a look and see why it isn't please.
Allan
Here is my code. How to convert DateTime Format at { "mDataProp": "DateCreate" }
Thanks for the code, however I don't see the issue from that I'm afraid. Can you give me a link to a page showing the issue, as I requested above, so I can offer some assistance.
Allan
Here is my result DateTime shown /Date(1433869200000)/. you can see as a picture
That's a .NET datetime object as a string. You have two options:
Allan
Thank you, Allan
I can adapt it with function and now I need to be put edit button to my datatables
How to do? in the same code on above.
Editor is the officially supported method for editing DataTables. If you use editor, I would suggest using its
GetFormatter
andSetFormatter
for date time fields. The .NET package includes examples of that.Allan
your suggestion page is 404 page not found.
I need to create datatables like attached picture.
how to change my code?
Sorry - I've corrected the link now - it just had a trailing
)
.Allan
Hello
I want to convert this date format /Date(1433869200000)/
Per my post above:
That's a .NET datetime object as a string. You have two options: