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

How to set auto complete or auto suggestion in text field in sap ui5 like sap.m.Input?

本文关键字:sap Input 例如 文本 ui5 字段 设置      更新时间:2023-09-26
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}"
    }));
}

它将错误显示为建议找不到项目。

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