})
Hi Minh,
Thanks for using Syncfusion Products.
We have analyzed your code snippet and we suggest you to bind a datasource explicit to the dropdown while using URL Adaptor. In URL Adaptor we retrieve only current page records so we could not bind complete datasource for dropdown. So we suggest you to bind datasource explicitly.
Please find the below code snippet :
@(Html.EJ().Grid<MvcApplication14.OrdersView>("FlatGrid") .Datasource(ds => ds.URL("BatchDataSource").BatchURL("BatchUpdate").Adaptor(AdaptorType.UrlAdaptor)) .AllowPaging() /*Paging Enabled*/ .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch); }) .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Add); items.AddTool(ToolBarItems.Edit); items.AddTool(ToolBarItems.Delete); items.AddTool(ToolBarItems.Update); items.AddTool(ToolBarItems.Cancel); }); }) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).EditType(EditingType.Dropdown).DataSource((List<object>)ViewData["EmployeeID"]).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Format("{0:MM/dd/yyyy}").Add(); col.Field("ShipCity").HeaderText("Ship City").Width(110).Add(); })) -------------------------------------------------------------------------------------------------- public ActionResult GridFeatures() { ViewData["EmployeeID"] = EmployeeID; return View(); } public List<object> EmployeeID { get { var employeeID = OrderRepository.GetAllRecords().Select(s => s.EmployeeID).Distinct().ToList(); var EmployeeID = new List<object>(); foreach (var id in employeeID) { EmployeeID.Add(new { value = id, text = id }); } return EmployeeID; } } |
For your convenience we have created a sample and sample can be downloaded from the below link
Sample Link : http://www.syncfusion.com/downloads/support/forum/118811/Sample-1267489255.zip
Please get back to us if you have any further assistance on this,
Regards,
Prasanna Kumar N.S.V