[Child.cshtml]
@{
List<object> toolbarItems = new List<object>();
toolbarItems.Add(new { template = "#template" });
var query = "new ej.data.Query()";
}
<div id="template" type="text/x-template">
<div>
@Html.EJS().DropDownList("games").DataSource((IEnumerable<object>)ViewBag.dropDownData).Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings{ Text ="text", Value="value"}).Query(query).Render()
</div>
</div>
<br />
@Html.EJS().Grid("FlatGrid").DataSource((IEnumerable<object>)ViewBag.dataSource).Toolbar(toolbarItems).Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).Width("120").Add();
col.Field("CustomerID").HeaderText("Customer Name").Add();
col.Field("OrderDate").HeaderText("Order Date").Type("date").Width("110").Add();
col.Field("Freight").HeaderText("Freight").Width("120").Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();
}).AllowPaging().Render()
------------------------------------------------------------------------------------------------------------------------------------------------
[HomeController.cs]
public static List<CustomToolBar> dropDownData = new List<CustomToolBar>();
public ActionResult Child()
{
----
if (dropDownData.Count() == 0)
{
dropDownData.Add(new CustomToolBar() { text = "Add", value = "Add" });
dropDownData.Add(new CustomToolBar() { text = "Edit", value = "Edit" });
dropDownData.Add(new CustomToolBar() { text = "Delete", value = "Delete" });
dropDownData.Add(new CustomToolBar() { text = "Update", value = "Update" });
dropDownData.Add(new CustomToolBar() { text = "Cancel", value = "Cancel" });
}
ViewBag.dropDownData = dropDownData;
ViewBag.datasource = orddata.ToArray();
return View();
}
public class CustomToolBar
{
public CustomToolBar() { }
public CustomToolBar( string text, string value)
{
this.text = text;
this.value = value;
}
public string text { get; set; }
public string value { get; set; }
}
|