@Html.EJ().DropDownList("countryList").Datasource(ds => ds.URL(@Url.Action("GetCountries", "Home")).Adaptor(AdaptorType.UrlAdaptor)).DropDownListFields(Df => Df.Text("description").Value("code")).EnableFilterSearch(true).Width("100%").AllowVirtualScrolling(true).VirtualScrollMode(VirtualScrollMode.Continuous).EnableServerFiltering(true).ItemsCount(20) |
public JsonResult GetCountries(Syncfusion.JavaScript.DataManager value)
{
var query = value.Where; // you can access the Where query here
var jsonSerializer = new JavaScriptSerializer();
// getting Data
var countries = CountriesGet();
//Checking for server-side filtering
if (query != null)
{
var items = query.ToArray();
//checking for virtual scrolling on filtered list
if (value.Skip != 0)
{
var result = countries.Where(item => item.description.Contains(items[0].value.ToString())).Skip(value.Skip).Take(value.Take).ToList();
return Json(jsonSerializer.Serialize(result));
}
var res1 = countries.Where(item => item.description.Contains(items[0].value.ToString())).Take(value.Take).ToList();
return Json(jsonSerializer.Serialize(res1));
}
//Checking for virtual scrolling
if (value.Skip != 0)
{
var res1 = countries.Skip(value.Skip).Take(value.Take).ToList();
return Json(jsonSerializer.Serialize(new { result = res1, count = res1.Count }));
}
//returns on initial load
var res = countries.Take(value.Take).ToList();
return Json(jsonSerializer.Serialize(new { result = res, count = countries.Count }));
} |
This is great, but the features are not available in EJ2. Seems like very useful, but not supported?
Can you rewrite this sample for EJ2?
<div id='o-data' class='col-lg-6' style='padding-top:15px'> <div class='content'> @Html.EJS().DropDownList("customers").Placeholder("Select a customer").PopupHeight("200px").Open("onOpen").DataSource(dataManger => dataManger.Url("https://js.syncfusion.com/ejServices/Wcf/Northwind.svc/Orders/").Adaptor("ODataAdaptor").CrossDomain(true)).Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings { Value = "CustomerID" }).Query("new ej.data.Query().select(['CustomerID']).take(10)").Render() </div> </div> <script> var isInitial = false; function onOpen(args) { if (!this.isInitial) { var start = 11; var end = 20; var instance = document.getElementById("customers").ej2_instances[0]; var listElement = instance.popupObj.element.firstChild; listElement.addEventListener('scroll', () => { if ((listElement.scrollTop + listElement.offsetHeight >= listElement.scrollHeight)) { var filterQuery = this.query.clone(); this.dataSource.executeQuery(filterQuery.range(start, end)).then((event) => { start = end; end += 5; instance.addItem(event.result); }).catch((e) => { }); } }) } } </script> |
Hi Prince,
Thanks Advance !!!
In my Project using MVC with Entity Framework Solution. We fetch data from SQL database and using Entity Framework to get result IEnumerable List. Whether IEnumerable List values to pass the MVC Controller and Standard HTML Helper Dropdownlist to display the dropdown option values. Please suggest and provide the solution...
Hi Ranjith Kumar,
To create an Entity Framework in an MVC application, you can refer to the following resources. If you are facing any issue, kindly share sample with us for further investigation.
https://blazor.syncfusion.com/documentation/dropdown-list/data-binding#entity-framework
https://www.syncfusion.com/blogs/post/crud-app-asp-dotnet-core-entity-framework-visual-studio.aspx
https://www.syncfusion.com/blogs/post/crud-aspnetcore5-entityframework.aspx
https://www.syncfusion.com/forums/124380/searching-with-entity-framework
Additionally, we'd like to inform you that starting from version 23.1.36, we provide built-in support for virtualization. You can find more information about this feature in the release notes.
Release Notes: https://ej2.syncfusion.com/aspnetmvc/documentation/release-notes/23.1.36?type=all#dropdownlist
For further reference and demos about virtualization, you can explore the following resources:
Documentation: https://ej2.syncfusion.com/aspnetmvc/documentation/drop-down-list/virtual-scroll
Demos: https://ej2.syncfusion.com/aspnetmvc/DropDownList/VirtualScroll#/material3
Regards,
Yohapuja S