I came up with solution which delivers small amount of data (100 entries) to dynamic list. It happens dynamically as user starts to type in some letters in field. This works well for dynamic list's result view, but it is not good for autocomplete part, where it uses some cached data from past and is not true anymore on such dynamic data updates. So I made a delayed feed of the data, just a second later after the autocomplete is triggered on user 'keyup' event. So far it works smoothly and doesn't crash the browser.
The complete idea:
1) On page load do the ajax request to get full data list - 13000 records in our case.
2) Save this list in JavaScript variable (do not give it to dynamic list or it will crash the browser because of data amount)
$.getJSON('/rest-ws/service/result/raw?esql=select+strvendorref+from+dms%3Avendor+where+catcompany+%3D+%27' + company + '%27+order+by+strvendorref')
.done(function(data){
function remapData (v){
return { value: v.strvendorref };
}
vendorsData = $.makeArray($.map(data, remapData));
});
3) with jQuery attach following 'keyup/keydown' event triggers for dynamic list's input field in html DOM.
keydown - clears all previous the dynamic list entries.
$('[placeholder="Vendor"].eo-autocomplete-input').keydown(function(e){if (!~$.inArray(e.keyCode,skipKeys)) { vendorlist.setList({ config: { allelementsselectable: true }, entries: [] }); } });
keyup - after 1 sec delay filters first 100 matched entries from JavaScript data variable and attaches to dynamic list
$('[placeholder="Vendor"].eo-autocomplete-input').keyup(function(e){ if (!~$.inArray(e.keyCode,skipKeys)) { let val = $(this).val().toLowerCase();
let items = _.filter(vendorsData, item => item.value.toLowerCase().includes(val)).slice(0,100); clearTimeout(timeOutRef); timeOutRef = setTimeout(function toPreventAutocomplete(){ vendorlist.setList({ config: { allelementsselectable: true }, entries: items }); },1000); }});
4) after user had entered few characters in field, he/she can open dynamic list results view where only filtered results are loaded and select the required one.