Custom sort events do not fire

Custom sort events do not fire

ardpardp Posts: 1Questions: 0Answers: 0
edited August 2012 in General
Probably I´m doing something wrong but I read all documents and tryed hard to find what and really I can´t find it.

I´m from Brazil and speack Portuguese, I´m trying to make Datatable sort disconsider accented characteres using a custom sort function, but it does not fire the function.

My table code is that one:

[code]
$('.tabelaResultadoBusca').dataTable({
'bAutoWidth' : false,
'bSortClasses' : false,
'iDisplayLength': maxRecordsPerPage,
'bFilter' : false,
'sPaginationType' : 'full_numbers',
'bInfo' : false,
'bLengthChange': false,
'aaSorting': [[ 1, 'asc' ]],
'aoColumnDefs': [
{
'sType': 'num-html',
'aTargets' : [0]
}
]
});
[/code]

And I´m using this code on as a custom plug in:

[code]
function ClearAccent(palavra) {
com_acento = 'áàãâäéèêëíìîïóòõôöúùûüç';
sem_acento = 'aaaaaeeeeiiiiooooouuuuc';
nova = '';
palavra = palavra.toLowerCase();

for (i = 0; i < palavra.length; i++) {
if (com_acento.search(palavra.substr(i, 1)) >= 0) {
nova += sem_acento.substr(com_acento.search(palavra.substr(i, 1)), 1);
}
else {
nova += palavra.substr(i, 1);
}
}
return nova;
}

jQuery.fn.dataTableExt.aTypes.unshift(
function ( sData ) {
return 'html';
}
);

jQuery.fn.dataTableExt.aTypes.unshift( function ( sData )
{
sData = typeof sData.replace == 'function' ?
sData.replace( /<.*?>/g, "" ) : sData;
sData = $.trim(sData);

var sValidFirstChars = "0123456789-";
var sValidChars = "0123456789.";
var Char;
var bDecimal = false;

/* Check for a valid first char (no period and allow negatives) */
Char = sData.charAt(0);
if (sValidFirstChars.indexOf(Char) == -1)
{
return null;
}

/* Check all the other characters are valid */
for ( var i=1 ; i/g, "");
var y = b.replace(/<.*?>/g, "");

x = parseFloat(x);
y = parseFloat(y);

return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
var x = a.replace( /<.*?>/g, "" );
var y = b.replace( /<.*?>/g, "" );
x = parseFloat( x );
y = parseFloat( y );

return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};

$.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.value );
} );
return aData;
}

$.fn.dataTableExt.afnSortData['dom-select'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') select', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( $(this).val() );
} );
return aData;
}

$.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.checked==true ? "1" : "0" );
} );
return aData;
}
[/code]

Can some one guive me a help to see where is my mistake please ?
This discussion has been closed.