I am building a web app in ASP.NET Core using Razor Pages. However, i also wanted to try using some javascript to display a datatable. I want to display the properties StartTime, EndTime, and Added, which are of the type DateTime. But i cannot get it to work without doing a lot of background conversions.
My question is, what would be the simplest way to display the values stored in the DateTime properties?
This is what my js-file looks like, it displays information from an object of the custom class Shift:
$(document).ready(function () {
$('#DT_load').DataTable({
"ajax": {
"url": "/api/Shift",
"type": "GET",
"datatype":"json"
},
"columns": [
{ "data": "user.name", "width": "25%" },
{ "data": "location.name", "width": "25%" },
{**<!-- Here i want to display DateTime properties values -->**
"data": "id",
"render": function (data) {
return `<div class="w-75 btn-group" >
<a href="/Admin/Shifts/upsert?id=${data}" class="btn btn-success text-white mx-2">
<i class="bi bi-pencil-square"></i> </a>
<a href="/Admin/Shifts/upsert?id=${data}" class="btn btn-danger text-white mx-2">
<i class="bi bi-trash-fill"></i> </a>
</div>`
},
"width":"15%"
},
],
"width":"100%"
});
});
I am using a controller that gets all properties with specific properties, but including the properties doesn't work either.