Accent neutralise search & localeCompare sorting

Accent neutralise search & localeCompare sorting

MertakMertak Posts: 4Questions: 1Answers: 0

Hello guys,

i need use sorting table and search with Czech characters like Ě,Š,Č,Ř,Ž etc. I want use localeCompare for sorting and Accent neutralise in the same time for search. Its possible use it both? I cant find solution :-/

localeCompare without Accent neutralise works fine... Accent neutralise without localeCompare it also works, but both in same time not working. Have someone better solution for this?

Here is example:
jsfiddle.net/rc4wxnc7/9/

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Took me a few minutes to figure out what was going on there, but the issue was that the plug-ins were being attached to two different column types (locale-compare for the sort and string for the filter). A column can only have one type, so we need to use the same for both plug-ins.

    Adjusting the name of the filtering plug-in allows it to work as expected: https://jsfiddle.net/rc4wxnc7/10/ .

    Regards,
    Allan

  • MertakMertak Posts: 4Questions: 1Answers: 0

    Hi Allan,

    thanks for reply and solution :-) But not working properly. When write to search form "ada" the script show "Áda" row... and now comes problem. When write to search "Áda" so page doesn't show row with "Áda". Have solution for this?

    Regards,
    Mertak

  • HPBHPB Posts: 73Questions: 2Answers: 18
    edited June 2017 Answer ✓

    You're removing the accent from the data you're comparing against, but you're not from the filter.

    Do both to get the expected result:
    https://jsfiddle.net/ep7d6as0/

  • MertakMertak Posts: 4Questions: 1Answers: 0

    Omg :smile: I tested the same solution but I had a little mistake in it :smile: Thanks HPB and allan

  • HPBHPB Posts: 73Questions: 2Answers: 18
    Answer ✓

    This still does a double search on the datatable if a character with an accent is entered in the filter box.

    For reference purposes I'd like to propose a cleaner solution.
    In this fiddle I removed the default behaviour and added a change listener with expected behaviour.
    https://jsfiddle.net/d9vtu79g/

  • MertakMertak Posts: 4Questions: 1Answers: 0

    I use little diferent script like you, but your script looks better than my :smile: Thx HPB for big help :-)

  • toniux79toniux79 Posts: 21Questions: 7Answers: 0
    edited October 2017

    Hello all (sorry first for my english..)

    I have 2 questions about the last answer of HPB https://jsfiddle.net/d9vtu79g/ :
    * The cross allowing to delete the global search field does not work anymore ?
    * I don't get how to know what is the name to set for the selector name in the example $('#example_filter input') ? In the Accent Neutraliser plugin example, the selector name was $('#myInput')... It is not clear for me..

    thank you

  • Chris_fr7Chris_fr7 Posts: 3Questions: 1Answers: 0

    hello,

    The solution (https://jsfiddle.net/d9vtu79g/ works very well.

    I have a stupid problem.

    I can not integrate it with my script : " $('.datatable-basic').DataTable({
    "order": [[ 0, "desc" ]],
    "columnDefs":
    [{"targets": [ 0 ],
    "visible": true, ...

    Thank you very much for your help.

    Chris

This discussion has been closed.