on 04-11-2018 3:23 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.