I have the below sample code that gets a list of vendors.
public IEnumerable VendorList()
{
var list = new List<SelectListItem>();
IEnumerable<Vendor> vendorList = this.db.Vendors.OrderBy(n => n.VendorID).ToList();
foreach (Vendor vendor in vendorList)
{
list.Add(new SelectListItem { Value = Convert.ToString(vendor.ID), Text = vendor.VendorID });
}
return list;
}
I'm then putting the list in a VendorList viewbag like below
[NoCache]
private void GetData()
{
ViewBag.VendorList = this.VendorList();
}
I'm then displaying my list in an mvc dropdown below
@Html.DropDownList("ddlVendorList", ViewBag.VendorList as IEnumerable<SelectListItem>, "Select Vendor", new { @class = "form-control input-sm-mfc-dropdownlist select2" })
The problem i'm having is that the dropdownlist is unresponsive because the number of rows in the list is a lot. I'm using select2 to enable the user type in the dropdown so that they can get auto suggest support other than scrolling a dropdownlist of more than 6768 items.
Is there a way i can partially load data depending on what the user is typing, something like say a batch of 20 rows as the user types?
Below is how i'm simply initializing select2
$(".select2").select2();