sorting field according to months description
sorting field according to months description
How to sort the fields according to moths description . i try using the following code
[code]
var monthsArray=new Array("Gennaio","febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","novembre","dicembre");
jQuery.fn.dataTableExt.oSort['string-case-asc'] = function(x,y) {
alert( "asc");
var indexOfx = monthsArray.indexOf(x);
var indexOfy = monthsArray.indexOf(y);
return ((indexOfx < indexOfy) ? -1 : ((indexOfx > indexOfy) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['string-case-desc'] = function(x,y) {
alert( "desc");
var indexOfx = monthsArray.indexOf(x);
var indexOfy = monthsArray.indexOf(y);
return ((indexOfx < indexOfy) ? 1 : ((indexOfx > indexOfy) ? -1 : 0));
};
$(document).ready(function() {
$('#example').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"aoColumnDefs": [
{ "sType": 'string-case', "aTargets": [ 0 ] }
],
"bAutoWidth": false
});
} );
[code]
but not working properly any ideas ....
[code]
var monthsArray=new Array("Gennaio","febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","novembre","dicembre");
jQuery.fn.dataTableExt.oSort['string-case-asc'] = function(x,y) {
alert( "asc");
var indexOfx = monthsArray.indexOf(x);
var indexOfy = monthsArray.indexOf(y);
return ((indexOfx < indexOfy) ? -1 : ((indexOfx > indexOfy) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['string-case-desc'] = function(x,y) {
alert( "desc");
var indexOfx = monthsArray.indexOf(x);
var indexOfy = monthsArray.indexOf(y);
return ((indexOfx < indexOfy) ? 1 : ((indexOfx > indexOfy) ? -1 : 0));
};
$(document).ready(function() {
$('#example').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"aoColumnDefs": [
{ "sType": 'string-case', "aTargets": [ 0 ] }
],
"bAutoWidth": false
});
} );
[code]
but not working properly any ideas ....
This discussion has been closed.
Replies
http://www.datatables.net/plug-ins/sorting
This might be easily changed for your need.
Allan