Bonjour,
j'explique la situation.

J'ai une liste (bd) avec des enregistrement où des accents se trouvent.

J'ai aussi une zone de recherche avec un champ 'searchfield'

actuellement j'ai un script qui fonctionne basiquement, c'est à dire qu'il faut taper la sous chaine exacte. Si on veut les enreg qui contiennent école ou ecole on doit le faire en deux fois car il compare exactement .


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Ext.define('proto.controller.Test', {
    extend: 'Ext.app.Controller',
 
    config: {
        refs: {
            main: 'mainpanel'
        },
        control: {
            'testlist': {
                disclose: 'showDetail'
            }
 
        }
    },
 
    showDetail: function(list, record) {
        this.getMain().push({
            xtype: 'testdetail',
            title: record.fullName(),
            data: record.getData()
        })
    },
 
	  init: function() {
 
        this.control({
 
            '#test_search':{  
                scope: this,
                clearicontap: this.onSearchClearIconTap,
                keyup: this.onSearchKeyUp
            }
 
        });
    },
 
 
    onSearchKeyUp: function(field) {
        //get the store and the value of the field
        var value = field.getValue(),
        store = Ext.getCmp('testlist').getStore();    //  getting the store that drives the contact list
 
        //first clear any current filters on thes tore
        store.clearFilter();
 
        //check if a value is set first, as if it isnt we dont have to do anything
        if (value) {
            //the user could have entered spaces, so we must split them so we can loop through them all
            var searches = value.split(' '),
            regexps = [],
            i;
 
            //loop them all
            for (i = 0; i < searches.length; i++) {
 
                //if it is nothing, continue
                if (!searches[i]) continue;
 
                //if found, create a new regular expression which is case insenstive
               // regexps.push(new RegExp(searches[i], 'i'));
             regexps.push(new RegExp(searches[i], 'i'));
 
			}
 
            //now filter the store by passing a method
            //the passed method will be called for each record in the store
            store.filter(function(record) {
                var matched = [];
 
                //loop through each of the regular expressions
                for (i = 0; i < regexps.length; i++) {
 
                              var search = regexps[i],
             didMatch = record.get('Name').match(search) ;//||
                              //    record.get('Description').match(search);
                            //if it matched the first or last name, push it into the matches array 
 
                               matched.push(didMatch);
 
                         }  //if nothing was found, return false (dont so in the store)               
 
              if (regexps.length > 1 && matched.indexOf(false) != -1) {
                              return false;
                          } else {
                             //else true true (show in the store)
                             return matched[0];
                            }
            });
        }
    },
 
    onSearchClearIconTap: function() {
 
        Ext.getCmp('testlist').getStore().clearFilter();
    }
 
 
 
});
j'ai essayé d'encapsuler la ligne suivante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
  didMatch = record.get('Name').match(search) ;
avec la fonction AccentToNoAccent au niveau du record.get mais sans succès.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	replaceAll: function(str, search, repl) {
 while (str.indexOf(search) != -1)
  str = str.replace(search, repl);
 return str;
},
AccentToNoAccent: function(str) {
 var norm = new Array('À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
'Ì','Í','Î','Ï', 'Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý',
'Þ','ß', 'à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î',
'ï','ð','ñ', 'ò','ó','ô','õ','ö','ø','ù','ú','û','ü','ý','ý','þ','ÿ');
var spec = new Array('A','A','A','A','A','A','A','C','E','E','E','E',
'I','I','I','I', 'D','N','O','O','O','0','O','O','U','U','U','U','Y',
'b','s', 'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i',
'i','d','n', 'o','o','o','o','o','o','u','u','u','u','y','y','b','y');
 for (var i = 0; i < spec.length; i++)
  str = replaceAll(str, norm[i], spec[i]);
 return str;
 }
}

Comment faites-vous pour effectuer une recherche de ce genre et/ou intégrer la fonction afin que cela fonctionne.

Merci