2016-03-10 70 views
2
this code is written in my controller. 
var textField = new sap.ui.commons.TextField({ 
    editable: true, 
    liveChange:this._suggest.bind(this) 
    }).bindProperty("value", name); 
    _suggest:function(oevent){//this method is called for auto sugggest 
    oEvent.getSource().bindAggregation("suggestionItems", path, 
    new sap.ui.core.Item({ 
      text: "{name}" 
    })); 
} 

它顯示錯誤爲建議itemstems找不到。如何在sap ui5的文本字段中設置自動完成或自動建議,如sap.m.Input?

+0

爲什麼不['輸入 - Suggestions'](https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputSuggestionsCustomFilter/preview) – Rayon

+0

因爲我想要使用ui.commons.textfield作爲米尺寸比要求更大...所以請這麼一些建議.. –

+0

不幸的是,我無法執行您的代碼..如果可能的話提供一個JSBin .. – Rayon

回答

1
var oFiled = new sap.ui.commons.AutoComplete({ 
    editable: true, 
    suggest: this._autoSuggest.bind(this) 
}).bindValue("name"); 

_autoSuggest: function() { 
    for (var i = 0; i < aData.length; i++) { 
     if (jQuery.sap.startsWithIgnoreCase(aData[i].name, sValue)) { 
      oEvent.getSource().addItem(new sap.ui.core.ListItem({ 
       text: aData[i].name 
      })); 
     } 
    } 
} 
相關問題