Sort without accents

Sort without accents

ivanlopesivanlopes Posts: 4Questions: 0Answers: 0
edited March 2014 in DataTables 1.9
Hello There,

Im having problem sorting word that have accent. i found a post here that a guy named rbraga found a solution.
The solution was that the code snippet that he wrote remove all accent before sorting. but i can't understand how to use the code, in fact i thing the code is incomplete:

at jquery.dataTables.js

[code]
function removeAccents(strAccents){
strAccents = strAccents.split('');
strAccentsOut = new Array();
strAccentsLen = strAccents.length;
var accents = '

I would really love if someone could help me on this, please.


Ivan Lopes

Replies

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Have a look at this page: http://next.datatables.net/plug-ins/filtering/type-based/accent-neutralise

    Allan
  • ivanlopesivanlopes Posts: 4Questions: 0Answers: 0
    Thank you! I tried that plugin but give me an error:

    "Uncaught TypeError: Cannot read property 'search' of undefined "

    then i did some research on the internet and i found a guy that says to replace

    jQuery.fn.DataTable.ext.type.search.string to this $.fn.dataTableExt.ofnSearch['string']

    and the error was gone. But when i used the .keyup function () from my input i got the same error:

    "Uncaught TypeError: Cannot read property 'search' of undefined ".

    So i went to the "table.search" and replace it with : table.ofnSearch['string'].

    The error was gone but its not working. its sorting but dont remove the accent.

    Im sorry.
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    The plug-in required DataTables 1.10 - sorry, I should have mentioned that.

    Allan
  • ivanlopesivanlopes Posts: 4Questions: 0Answers: 0
    ok i've changed the version. But now i get this:

    Uncaught TypeError: Object [object Object] has no method 'search' .

    Its sorting and filtering but not with accents.

    :(
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Can you link me to the page please, so I can take a look and see what is going wrong?

    Allan
  • ivanlopesivanlopes Posts: 4Questions: 0Answers: 0
    edited March 2014
    Ok! go here http://urgimed.cv/enf/
    Click on "Nova Utilização" and wait a little to load the table.
    One thing i think you should know. Im loading the table inside a div using jquery .load().
    Thank you very much
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Hi,

    I made a mistake in my original reply - sorry about that. I posted you to a filtering plug-in that would neutralise accents for filtering - not for sorting...

    For accent sorting, take a look at this plug-in: http://datatables.net/plug-ins/sorting/chinese-string . I've found that in old version of IE the sorting is a bit odd, due to an error in old IE, but it should work in newer browsers.

    See this example for how to use the plug-in.

    Allan

This discussion has been closed.