I’m trying to setup the autocomplete with ID as textProperty and NAME as valueProperty, and getting most working. After it is selected a choice; however, what shows in the text field is the ID, instead of NAME. Most examples is NAME as textProperty and valueProperty. I couldn’t find others having the same issue. I probably did something wrong. I’m struggle with this for quite sometimes. Any suggests would be really appreciated.
For example, AJAX returns data = [{ID:“1”,NAME:“White Car”},{ID:“2”,NAME:“Black Car”},{ID:“3”,NAME:“Green Car”}]
After I select “Black Car” I’m expecting it shows “Black Car” in the text field, not “1”.
Thanks.
app.autocomplete.create({
inputEl: '#product-autocomplete', //link that opens autocomplete
openIn: 'dropdown', //open in page
valueProperty: 'ID', //object's "value" property name
textProperty: 'NAME', //object's "text" property name
source: function (query, render) {
var autocomplete = this;
var results = [];
if (query.length === 0) {
render(results);
return;
}
app.request({
url: host + 'getProductByKeywords',
method: 'GET',
dataType: 'json',
data: {
keywords: query
},
success: function (data) {
// ex. data = [{ID:"1",NAME:"White Car"},{ID:"2",NAME:"Black Car"},{ID:"3",NAME:"Green Car"}]
render(data);
}
});
},
});