0
In my project I’m using the library Datatables for mounting of my tables, the problem is that it is returning the date in the standard american (format I write to the database) and am unable to customize to display in the pattern brazilian DD/MM/YYYY.
I’ve tried using jQuery masks but they change only the first record, the following remain in American format. I tried to use Moment.js but could not implement. Below my codes and a table print.
Custom JS from Datatables
$(document).ready(function () {
$("#table").dataTable({
aLengthMenu: [
[5, 10, 25, -1],
[5, 10, 25, "Todos"],
],
iDisplayLength: 5,
"language": {
"url": "https://cdn.datatables.net/plug-ins/1.10.20/i18n/Portuguese-Brasil.json"
}
});
});
Table:
<div class="jumbotron">
<div class="card-header">
<h3 class="display-5">
<i class="fas fa-ticket-alt fa-lg"></i>
Tickets Abertos
<a asp-action="NovoTicket" class="btn btn-primary btn-lg" data-toggle="tooltip" data-placement="right" title="Novo Ticket">
<i class="fas fa-plus-circle fa-lg"></i>
</a>
</h3>
</div>
<div class="card-body">
<table id="table" class="table table-striped table-hover table-responsive-md">
<thead>
<tr>
<th>Id</th>
<th>Equipamento</th>
<th>PA</th>
<th>Problema</th>
<th>Data Abertura</th>
<th>Valor</th>
<th>Status</th>
<th>Responsável</th>
<th>Opções</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.TicketId)</td>
<td>@Html.DisplayFor(modelItem => item.Equipamento.TipoDeEquipamento)</td>
<td>@Html.DisplayFor(modelItem => item.PA.Nome)</td>
<td>@Html.DisplayFor(modelItem => item.Descricao)</td>
<td">@Html.DisplayFor(modelItem => item.DataAbertura)</td>
<td>R$ @Html.DisplayFor(modelItem => item.Valor)</td>
<td>@Html.DisplayFor(modelItem => item.Status)</td>
<td>@Html.DisplayFor(modelItem => item.Usuario.Nome)</td>
<td>
<a asp-action="AtualizarTicket" asp-route-TicketId="@item.TicketId" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Atualizar Ticket">
<i class="far fa-edit"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
Using the right culture, put in my project in precise English culture. Already trying to use Tostring in View I received the following error: "Invalidoperationexception: Templates can be used only with field access, Property access, single-Dimension array index, or single-Parameter custom indexer Expressions."
– João