2012-04-28 60 views
0

我正在嘗試在我的列表中執行搜索,並且我在docs.sencha.com中使用了搜索列表示例,但搜索功能無法搜索。SearchList對我的項目不起作用

我在定義搜索字段後編寫代碼。

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]; 
         } 
        }); 
       } 
     } 

我想要做的是當我在搜索字段中鍵入內容時,必須根據該字詞過濾列表。

回答

0

由於拼寫錯誤的,從

lenght -> length 

同時在for循環

變化。

enter image description here