<input type="text" id='customers' />
<script>
// initialize DropDownList component
var dropDownListObj = new ej.dropdowns.DropDownList({
// bind the DataManager instance to dataSource property
dataSource: new ej.data.DataManager({
url: '@Url.Action("UrlDatasource", "Home")',
adaptor: new ej.data.UrlAdaptor(),
crossDomain: true
}),
// map the appropriate columns to fields property
fields: { value: 'ShipCountry' },
// set the placeholder to DropDownList input element
placeholder: 'Select a name',
});
dropDownListObj.appendTo('#customers');
</script>
|
public JsonResult UrlDatasource([FromBody]Data dm)
{
var val = OrdersDetails.GetAllRecords();
var Data = val.ToList();
var count = val.Count();
if (dm.where != null)
{
Data = (from cust in Data
where cust.ShipCountry.ToLower().StartsWith(dm.@where[0].value.ToString())
select cust).ToList();
}
if (dm.take != 0)
Data = Data.Take(dm.take).ToList();
return Json(new { result = Data });
} |