Amarjeet Kumar
Amarjeet Kumar

Reputation: 79

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

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

it show a error as suggestionItems not found .

Upvotes: 2

Views: 2604

Answers (1)

Amarjeet Kumar
Amarjeet Kumar

Reputation: 79

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

Upvotes: 2

Related Questions