BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
@(Html.EJ().Grid<OrdersView>("FlatGrid") .Datasource(ds => ds.URL("/Grid/Datasource").Adaptor(AdaptorType.UrlAdaptor)) .AllowSorting() .AllowPaging() .AllowFiltering() .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) .FilterSettings(filter => { filter.FilterType(FilterType.Menu); }) .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).Type("number").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Left).Width(90).Add(); col.Field("ShipName").HeaderText("ShipName").Type("string").Width(200).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(80).Type("number").EditType(EditingType.Numeric).Format("{0:C}").Add(); col.Field("ShipCity").HeaderText("ShipCity").EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.dataSource2).Width(150).Add(); }) public ActionResult GridFeatures() { ViewBag.dataSource2 = City; return View(); } public List<object> City { get { var Orders = new NorthwindDataContext().OrdersViews.Select(x=>x.ShipCity).Distinct().ToList(); var ShipCity = new List<object>(); foreach (var id in Orders) { ShipCity.Add(new { value = id, text = id }); } return ShipCity; } |
Hi Gary Bettencourt,
Thanks for contacting Syncfusion support.
We have tested the reported issue at our end, the problem is occurring when using URLAdaptor with edit type as dropDown.
While setting the edit type as dropDown in URLAdaptor we need to bind the data source to dropDownList by using dataSource property. Because when we set the dropDown edit type, we need to binding the whole data for the particular field, but in URLAdaptor we are unable to get the Whole data of the particular field.
Please refer to the code example and sample,
@(Html.EJ().Grid<OrdersView>("FlatGrid")
.Datasource(ds => ds.URL("/Grid/Datasource").Adaptor(AdaptorType.UrlAdaptor))
.AllowSorting()
.AllowPaging()
.AllowFiltering()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.FilterSettings(filter => { filter.FilterType(FilterType.Menu); })
.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).Type("number").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Left).Width(90).Add();
col.Field("ShipName").HeaderText("ShipName").Type("string").Width(200).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(80).Type("number").EditType(EditingType.Numeric).Format("{0:C}").Add();
col.Field("ShipCity").HeaderText("ShipCity").EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.dataSource2).Width(150).Add();
})
)
[Controller]
public ActionResult GridFeatures()
{
ViewBag.dataSource2 = City;
return View();
}
public List<object> City
{
get
{
var Orders = new NorthwindDataContext().OrdersViews.Select(x=>x.ShipCity).Distinct().ToList();
var ShipCity = new List<object>();
foreach (var id in Orders)
{
ShipCity.Add(new { value = id, text = id });
}
return ShipCity;
}
}
Sample: http://www.syncfusion.com/downloads/support/directtrac/147364/ze/Sample_1473641544620873
In the above sample we have iterate the ShipCity field in orders table and add to the list value.
Note: While binding the data to dropdown we need to specify the text and value property.
Regards,
Sellappandi R