
|
let atcObj2: AutoComplete = new AutoComplete({
dataSource: countries,
fields: { value: 'Name' },
placeholder: 'e.g. Australia',
sortOrder: 'Ascending',
filterType: 'StartsWith',
change: ()=>{
localStorage.setItem("value", atcObj2.value);
if(localStorage.getItem('value') !== 'null'){suggestList.push(localStorage.getItem('value'));
suggestList = suggestList.filter(function(item, pos, self) {
return suggestList.indexOf(item) == pos;
});
}
},
focus: ()=>{
if(suggestList.length >0){
(atcObj2.dataSource as any) = suggestList;
atcObj2.dataBind();
let keyEventArgs: any = { preventDefault: (): void => { }, action: 'down', keyCode: 40, type: null };
(atcObj2 as any).onFilterUp(keyEventArgs);
(atcObj2 as any).popupObj.element.classList.add('e-suggestion');
}
},
filtering: (e: FilteringEventArgs) => {
let query: Query = new Query();
query = (e.text !== '') ? query.where('Name', 'startswith', e.text, true) : query;
e.updateData(countries, query);
(atcObj2 as any).popupObj.element.classList.remove('e-suggestion');
}
});
atcObj2.appendTo('#country'); |