@(Html.EJ().Grid<Object>("FlatGrid") .Datasource((System.Data.DataTable)ViewBag.dataSource) .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) .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("No").HeaderText("ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Add(); . . . . . . . col.Field("PersonGender").EditType(EditingType.Dropdown).Add(); col.Field("DOB").EditType(EditingType.Datepicker).Add(); col.Field("Active").EditType(EditingType.Boolean).Add(); })) |
@(Html.EJ().Grid<Object>("FlatGrid") . . . . . .Columns(col => { . . . col.Field("PersonGender").EditType(EditingType.Dropdown).DataSource((IEnumerable<object>)ViewBag.dropData).Add(); . . . })) public ActionResult Index() { . . . . . . List<object> dropData = new List<object>(); dropData.Add(new { text = "1", value = 1 }); dropData.Add(new { text = "2", value = 2 }); ViewBag.dropData = dropData; return View(); } |