如何在sap ui5中的文本字段中设置自动完成或自动建议,如sap.m.Input?

时间:2016-03-10 03:53:43

标签: javascript jquery sapui5

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

它显示错误,因为没有找到suggestionItem。

1 个答案:

答案 0 :(得分: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
            }));
        }
    }
}