2017-03-18 168 views
0

工作,我有這樣的代碼:鈦Appcelerator的搜索不與搜索欄

var search = Titanium.UI.createSearchBar(); 

var myTemplate = { 
     properties: { 
       accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE, 
      }, 
     childTemplates: [ 
      {        
       type: 'Ti.UI.Label',  
       bindId: 'destinazione', 
       properties: { 
        left: '24%' 
       } 
      }, 
     ] 
    }; 

    var listView = Ti.UI.createListView({ 
     templates: { 'template': myTemplate }, 
     defaultItemTemplate: 'template', 
     searchView: search 
    }); 

恢復數據後與onload事件

xhrPart.onload = function() { 
     partenzeJSON = JSON.parse(this.responseText); 
     for (i in partenzeJSON){  
      var flightSection = Ti.UI.createListSection(); 
      var flightDataSet = []; 

      flightDataSet = [{ 
       destinazione: {text: partenzeJSON[i].destinazione, searchableText: partenzeJSON[i].destinazione}, 
      }]; 
      flightSection.setItems(flightDataSet); 
      sections.push(flightSection); 
     } 
     listViewPartenze.setSections(sections); 
    }; 

進入,因爲研究不工作? 不尋找列表視圖中的數據輸入

謝謝!!!

回答

2

searchableText已進入對象的屬性,而不是爲label

它應該是這樣的:

flightDataSet = [{ 
    destinazione: {text: partenzeJSON[i].destinazione}, 
    properties: {searchableText: partenzeJSON[i].destinazione} 
}];