Galera, tenho as seguintes colunas na minha tabela, e uma delas é o "Month" ele recebe um int que é referente ao numero do mes (1 - Jan, 2 - Fev, etc) Quando a tela carrega a tabela exibe os meses na ordem certa porém se eu clico pra ordenar, ele ordena por ordem alfabetica, como faço pra ordenar pela sequencia dos meses?
var colsCurrency = [
{ data: 'Year', orderable: true, className: 'col-sm-2 text-center', title: 'Year' },
{
data: 'Month', orderable: true, className: 'col-sm-2 text-center', title: 'Month', render: function (data) {
month = data;
switch (month) {
case 1:
colMonth = "January";
break;
case 2:
colMonth = "February";
break;
case 3:
colMonth = "March";
break;
case 4:
colMonth = "April";
break;
case 5:
colMonth = "May";
break;
case 6:
colMonth = "June";
break;
case 7:
colMonth = "July";
break;
case 8:
colMonth = "August";
break;
case 9:
colMonth = "September";
break;
case 10:
colMonth = "October";
break;
case 11:
colMonth = "November";
break;
case 12:
colMonth = "December";
break;
}
return colMonth;
}
},
{ data: 'Name', orderable: true, className: 'col-sm-2 text-center', title: 'Type' },
{
data: 'ValueUsTax', orderable: true, className: 'col-sm-2 text-center', title: 'Tx Dollar', render: function(data, type, full) {
return parseFloat(data).toFixed(4);
}},
{
data: 'ValueCcyFactor', orderable: true, className: 'col-sm-2 text-center', title: 'CCY Factor', render: function (data, type, full) {
return parseFloat(data).toFixed(4);
}
},
{
data: null, orderable: false, className: 'text-center col-sm-1', title: 'Actions', render: function (data, type, full) {
if (data.ActiveFlag) {
var retorno = '<nobr><button type="button" class="btn btn-xs btn-default" title="Edit" onclick="EditCurrencyById(' + full.CurrencyId + ')"><i class="glyphicon glyphicon-pencil"></i></button> ';
retorno += '<button type="button" class="btn btn-xs btn-danger" title="Delete" onclick="DeleteCurrency(' + full.CurrencyId + ')"><i class="glyphicon glyphicon-remove"></i></button></nobr>';
return retorno;
}
else {
var retorno = '<button type="button" class="btn btn-xs btn-primary" title="Active" onclick="Active(' + full.CurrencyId + ')"><i class="glyphicon glyphicon-off"></i></button></nobr>';
return retorno;
}
}
}
];
$('#idDaTabela').DataTable( { "order": [[ 2, "asc" ]] } );
Fonte aquidisplay: none
na célula e pode usar a função que mandei referenciando o indice da coluna