4
I am using the Bootstrap SB Admin2, which makes use of the component Datatables.
On my jsp page I am loading the following table:
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Código</th>
<th>Nome RCA</th>
<th>Meta</th>
</tr>
</thead>
<tbody>
<c:forEach var="rca" items="${listaTeste }">
<tr class="odd gradeX">
<td>${rca.codusur }</td>
<td>${rca.nome }</td>
<td style="text-align: right">${rca.meta }</td>
</tr>
</c:forEach>
</tbody>
</table>
and the following code for javascript:
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true,
"order": [2, 'asc']
});
});
</script>
That way the code works, example result:
2512 Aa 227,27
5769 Ma 2.318,18
2945 Mb 4.772,72
However, if I ask for jstl formatting in this way:
<td style="text-align: right"><fmt:formatNumber value="${rca.meta }" type="currency" /></td>
The table is ordered like this:
5769 Ma R$ 2.318,18
2512 Aa R$ 227,27
2945 Mb R$ 4.772,72
From what I understand it seems that he is reading as string, some solution to this case? I have looked at the documentation and found nothing.
PS: I apologize for the length of the question, I’m new here, but I wanted to explain all the details.
I tried to change the Pattern in fmtNumber using pattern="#,##0.00"
, and the classification remains wrong, but using pattern="0.00"
only then can he classify.
You tried using this plugin: http://datatables.net/plug-ins/sorting/currency?
– Tobias Mesquita
I tried, this plugin already came along with the datatable. Just to see if I understood: is he the one who would do the formatting? Or would I have to take fmt out of the code? Because in both cases I couldn’t make it work.
– JamesOrtiz