jquerysortingdatatableturkish

Jquery datatable column sorting in Turkish


I have a problem with the column sorting in jQuery Datatable. According to Turkish alphabet, the order of the datatable sorting is not correct. How can I achieve to get the correct result of the sorting Turkish ?


Solution

  • you can solve this issue with replacing _fnEscapeRegex function like this // _fnEscapeRegex fonksiyonunu aşağıdaki gibi değiştirerek bu sorunu çözebilirsiniz...

    function _fnEscapeRegex ( sVal ) {
    
    var letters = { "İ": "[İi]", "I": "[Iı]", "Ş": "[Şş]", "Ğ": "[Ğğ]", "Ü": "[Üü]", "Ö": "[Öö]", "Ç": "[Çç]", "i": "[İi]", "ı": "[Iı]", "ş": "[Şş]", "ğ": "[Ğğ]", "ü": "[Üü]", "ö": "[Öö]", "ç": "[Çç]" };
            var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ];
            var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
            sVal=sVal.replace(reReplace, '\\$1');
    
            return sVal.replace(/(([İIŞĞÜÇÖiışğüçö]))/g, function (letter) { return letters[letter]; });
        }