0

docs.sencha.com の検索リストの例を使用してリストを検索しようとしていますが、検索機能が検索されません。

検索フィールドを定義した後、コードをビューに記述します。

    xtype: 'textfield',
       docked: 'top',
       placeHolder: 'Arama...',
       //autoCapitalize: true,
       //  label: 'Anahtar Kelime',
       labelWidth: '`',
       listeners : {
              scope.this,
              keyup : function(field) {         
                      var value = field.getValue();
                      if (!value) {
                           Menius.filterBy(function()  {
                                 return true;
                           };
                      } ;                                            
                      else {
                           var searches = value.split(' '),
                           regexps = [],
                           i;
                           for(i=0; i< searches.lenght; i++) {
                                  if(!searches[i])
                                        return;
                                  regexps.push(new RegExp(searches[i], 'i'));
                           };
                          Menius.filterBy(function(record){
                          var matched = [];
                          for(i=0; i<regexps.lenght; i++) {
                              var search = regexps[i];
                              if (record.get('label').match(search))  
                                    matched.push(true);
                              else matched.push(false);
                          };


                         if (regexps.length > 1 && matched.indexOf(false) != -1)  {
                                return false;
                         } else {
                                return matched[0];
                         }
                   });
                 }
        }

私がやりたいことは、検索フィールドに何かを入力すると、その単語に従ってリストをフィルタリングする必要があることです。

4

1 に答える 1

0

スペルミスのため、

から変更する

lenght -> length

両方の for ループで。

ここに画像の説明を入力

于 2012-04-28T17:26:51.913 に答える