on 03-30-2016 8:34 AM
Hi experts,
I am trying to show a suggestion list when user types a username in an "Input"(sap.m.Input) field.
The filtering works for first username but for the next username it does not work.
The input field is defined as follows:
<Input
id="productInput"
type="Text"
placeholder="Place Holder"
liveChange="setSuggestion"
suggestionItems="{username>/names}"
suggest="handleSuggest"
width="auto">
<suggestionItems>
<core:Item text="{username>name}" />
</suggestionItems>
</Input>
The functions are set as follows:
setSuggestion:function(oEvent){
if(oEvent.getParameter("newValue").endsWith('@')){
console.log("Suggest");
lv_start_pos = oEvent.getSource().getFocusInfo().cursorPos - 1 ;
this.getView().byId('productInput').setShowSuggestion(true);
}else if(oEvent.getParameter("newValue").endsWith(' ')){
console.log("Do not Suggest");
lv_start_pos = undefined;
this.getView().byId('productInput').setShowSuggestion(false);
}
},
handleSuggest:function(oEvent){
var sTerm = oEvent.getParameter("suggestValue").slice(lv_start_pos,oEvent.getSource().getFocusInfo().cursorPos);
var aFilters = [];
if (sTerm) {
aFilters.push(new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.StartsWith, sTerm));
}
oEvent.mParameters.suggestValue = sTerm;
oEvent.getSource().getBinding("suggestionItems").filter(aFilters);
}
Here whenever user types @ the username has to be shown.
Hence the username is extracted using the setSuggestion function.
The names are defined as:
{
"names":[{"name":"@skk","id":"skkk"},
{"name":"@ajjj","id":"ajjj"}
]
}
In the input field when for the first time when user types the username the suggestion list is displayed.
For ex: On typing "@" the usernames in the json are displayed. Now on selecting one entry from the list, on continuing to type as follows:
"@ajjj @"
the list is not displayed further.
Is there any way I can achieve the list display again?
Thanks in advance.
Thanks and Regards,
Sarath
Hi Sarath,
You may have to use MultiInput and make sure only one item would be selected. May be this sample helps? JS Bin - Collaborative JavaScript Debugging
Snippet:
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.