[CLOSED] Filtering using FilterHeader plugin and Turkish language

  1. #1

    [CLOSED] Filtering using FilterHeader plugin and Turkish language

    Hi,
    I have an issue with using the FilterHeader plugin in a page where the language used is Turkish. In the Turkish character set, there are two types of I's:

    1) Dotted: i İ
    2) Undotted: ı I

    In the case of the FilterHeader plugin though, the filter fields cannot seem to make the correct distinction between the two types. I have added an image with the screenshots to show the problem. The list being filtered is a list of cities in Turkey. All the city names are capitalized, but the filter field is NOT case-sensitive.



    FILTERING WITH LOWERCASE DOTTED i (FILTERVALUE="i", OPERATOR="+") :

    Filtering should return İstanbul and İzmir only. But it also returns the record starting with uppercase undotted "I" -India.


    FILTERING WITH UPPERCASE DOTTED İ (FILTERVALUE="İ", OPERATOR="*"):

    Filtering should return İstanbul, İzmir and India, which all contain a dotted "i", uppercase and/or lowercase. But "India" is not returned.



    FILTERING WITH LOWERCASE UNDOTTED ı (FILTERVALUE="ı", OPERATOR="*"):

    Filtering should return both Dıyarbakır and India, but India, which has an uppercase undotted "I", is not returned.


    FILTERING WITH UPPERCASE UNDOTTED "I" (FILTERVALUE="I", OPERATOR="*"):

    Filtering should return India and Dıyarbakır only, yet Dıyarbakır is not returned. Furthermore, İstanbul and İzmir are returned, which have dotted i's.



    The sample code is quite simple, but let me know if you still require it, and I will post it here. Any help will be much appreciated.
    Attached Thumbnails Click image for larger version. 

Name:	All_cases.png 
Views:	80 
Size:	14.7 KB 
ID:	14691  
    Last edited by Daniil; Aug 22, 2014 at 7:55 AM. Reason: [CLOSED]
  2. #2
    Hi @metci,

    I've found this.
    http://stackoverflow.com/questions/1...-in-javascript

    I've tried the suggestion of Serkan Yersen and it appears to fix all the test cases that you mentioned.

    Please add this script into the page's <head>.
    <script>
        String.prototype.turkishToUpper = function () {
            var string = this;
            var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "?": "?", "?": "?", "?": "?", "ı": "I" };
            string = string.replace(/(([iışğ???]))+/g, function (letter) { return letters[letter]; })
            return string.toUpperCase();
        }
    
        String.prototype.turkishToLower = function () {
            var string = this;
            var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "?": "?", "?": "?", "?": "?" };
            string = string.replace(/(([İIŞĞ???]))+/g, function (letter) { return letters[letter]; })
            return string.toLowerCase();
        }
    
        Ext.net.FilterHeader.behaviour.getStrValue =  function (value) {
            return Ext.net.FilterHeader.behaviour.getOption("caseSensitive") || !value || Ext.net.FilterHeader.behaviour.isRemote() ? value : value.turkishToLower();
        }
    </script>
    You can see that I've overridden the Ext.net.FilterHeader.behaviour.getStrValue function to use the turkishToLower function instead of the native toLowerCase function.
  3. #3

    Thanks

    Thank you very much Daniil. Solution works well.
  4. #4
    The sample code is quite simple, but let me know if you still require it, and I will post it here.
    We are very happy if a member posts a standalone runnable test case in the original post.

Similar Threads

  1. Hide/Show FilterHeader Plugin
    By ADV in forum 2.x Help
    Replies: 2
    Last Post: Dec 24, 2013, 1:46 AM
  2. Replies: 1
    Last Post: Nov 23, 2013, 3:09 PM
  3. Replies: 4
    Last Post: Nov 19, 2013, 1:11 PM
  4. [CLOSED] FilterHeader Plugin Error
    By leonardm in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 21, 2013, 4:53 PM
  5. [CLOSED] Remote Filtering through Plugin 'GridFilters' with MVC
    By jesperhp in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 01, 2011, 3:10 PM

Tags for this Thread

Posting Permissions