Skip to Content
0

Input Suggestion Items List doesn't show up

Apr 11 at 02:23 PM

17

avatar image
Former Member

Hello Experts

I try to create an input field with suggested Items. Please have a look at my code (all in JS):

My View:

new sap.m.Input({

id: "input-suggestion",

placeHolder: "Enter search value",

showSuggestion: true,

suggest: function(oEvent) {

oController.handleSuggestTransmitter(oEvent);

},

startSuggestion: 2,

type: sap.m.InputType.Text

});

And now the controller:

handleSuggestTransmitter: function(oEvent) {

var vm = this;

var oTechnicalPlaceModel = new JSONModel(null);

vm.src = oEvent.getSource();

vm.src.setModel(oTechnicalPlaceModel, "oTechnicalPlaceModel");

var sSearchWord = oEvent.getParameter("suggestValue");

if (sSearchWord.trim().length > 1) {

var oDataServiceModel = vm.getComponent().getModel("ODataServiceModel");

if (!oDataServiceModel) {

var sErrorMsg = vm.getI18NText("load_exception", []);

MessageBox.show(sErrorMsg); return;

}

var oFilter = new sap.ui.model.Filter('Tplnr', 'EQ', sSearchWord);

var oSuggestionTemplate = new sap.m.InputListItem({

title: "{Tplnr}",

description: "{Raumc}",

active: true

});

var oParams = {

context: null,

urlParameters: null,

async: true.

filters: [oFilter],

sorters: [],

success: function(oData, oResponse) {

vm.src.getModel("oTechnicalPlaceModel").setData(oData);

vm.src.bindAggregation("suggestionItems", "/results", new sap.ui.core.Item({

text: "{Tplnr}",

key: "{Raumc}"

}), oSuggestionTemplate, null);


/* vm.src.setFilterFunction(function(sValue, oItem) {

return oItem.getText().match(new RegExp(sValue, "i"));

}); */

},

error: function(oError) {

var i18ntxt = "Error occured";

MessageToast.show(i18ntxt, {});

}

};


oDataServiceModel.read( "/TechPlatzSet", oParams ); }

},


I can see the items in my oData object (passed to the success function) but the list is not showing up.

Thanks a lot.

Regards,

Cengiz

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jun Wu Apr 11 at 03:09 PM
0

success: function(oData, oResponse) {

vm.src.getModel("oTechnicalPlaceModel").setData(oData);

vm.src.bindAggregation("suggestionItems", "

oTechnicalPlaceModel>/results", new sap.ui.core.Item({

text: "{oTechnicalPlaceModel>Tplnr}",

key: "{oTechnicalPlaceModel>Raumc}"

}

give it a try.

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Apr 11 at 03:10 PM
0

success: function(oData, oResponse) {

vm.src.getModel("oTechnicalPlaceModel").setData(oData);

vm.src.bindAggregation("suggestionItems", "

oTechnicalPlaceModel>/results", new sap.ui.core.Item({

text: "{oTechnicalPlaceModel>Tplnr}",

key: "{oTechnicalPlaceModel>Raumc}"

}

give it a try.

Share
10 |10000 characters needed characters left characters exceeded