Any suggestions on how to do a filtering dropdown control?
I need to provide a list of 700+ items but this is too long for the page to load. I was hoping I can allow the user to type in the dropdown control and when they get to at least 3 characters in length, do the search and populate the dropdown. Unfortunately, it turns out that you can't type in the dropdown control.
So, how can I lookup data from City and show it in a list on HR. I started with PnPJS but there are to many employees than can be loaded in one go. I need to filter the lookup as the user types the name.
And for filtering, you can add a TextBox field from the common field section which will filter the array of the values on change. Please see the code sample below.
let web = new Web('Site URL');
web.lists.getByTitle('List Name').items
.select('Title')
.get()
.then(function(items) {
var valuesArray = [];
items.forEach(function (element) {
valuesArray.push(element.Title);
});
var pat = fd.field('TextBox0').value;
filtered = valuesArray.filter(function (str) { return str.includes(pat); });
fd.field('DropDown0').widget.setDataSource({
data: filtered
});
});