How to set Predefined value to the AutocompleteTextview with javascript


#1

I have one autocompletetextview with customer names and I want to set predefined customer name to textfield of autocompletetextview .as that customer name is already in array which I am using for loading autocompletetextview.but as I am working with edit page I want to load Previously selected Customer name in autocompletetextview.
Please help to set predefined value to autocompletetextview.


#2

You can use the addToken method, examples can be found here.


#3

Hello,
I tried with Add token method but Some Undefined function e error is
giving. I want to show selected value to autocomplete text view I have that
values statically for example I have customer Name “1.Akshay Doiphode” I
want to show this in Text field of Autocomplete Textview.
Please Help.
Thank you in advance


#4

I suggest you to create a playground example where we can reproduce your issue.


#5

I am Using XML as:

<au:RadAutoCompleteTextView items="{{ items }}" suggestMode="Suggest"

displayMode=“Plain” completionMode=“Contains"
didAutoComplete=“onDidAutoComplete"
suggestionViewBecameVisible=”{{
onSuggestionViewBecameVisible }}” id=“autocmp” hint=“select Customer(min 3
letters)” >
au:RadAutoCompleteTextView.suggestionView
<au:SuggestionView suggestionViewHeight=“150”>
au:SuggestionView.suggestionItemTemplate



</au:SuggestionView.suggestionItemTemplate>
</au:SuggestionView>
</au:RadAutoCompleteTextView.suggestionView>
</au:RadAutoCompleteTextView>

for This autocompletexview I am Loading data from some URL in same case Now
I have One customer Name with me which I want to show as selected In
autocomplete textview’s textfield.

I am Loading data as:

autocmp = page.getViewById(“autocmp”);
autocmp.loadSuggestionsAsync = function (text1) {
var promise = new Promise(function (resolve, reject) {
console.log(“text111111”+text1);
if(text1.length>2){
http.getString(“
http://gandhigroup.com/P_order/getCustomers?q=” + text1).
then(function (html) {
var data= JSON.parse(html);
var items1 = new Array();

              for (var i = 0; i < data.length; i++) {
                    console.log("DATA ID"+data[i].id);
                    items1.push(new

autocompleteModule.TokenModel(""+data[i].id
+"-:"+data[i].text+"<"+data[i].price_code_id+">"));
};
resolve(items1);
})
, function (error) {
console.log("Error: " + error);
reject();
};
}
else {
reject();
}
});
return promise;
};

Thank you