[cshtml] @(Html.EJ().Grid<object> ("FlatGrid") . . . .Columns(col => { col.Field("Id").HeaderText("ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Email").HeaderText("Email").Width(80).Add(); col.Field("Nachname").HeaderText("Nachname").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Personalnummer").HeaderText("Personalnummer").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Status").HeaderText("Status").ForeignKeyField("Status").ForeignKeyValue("anzeige").DataSource((IEnumerable<object>)ViewBag.foreign).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Vorname").HeaderText("Vorname").TextAlign(TextAlign.Right).Width(75).Add(); })) [c#] public ActionResult GridFeatures() { var DataSource = new NorthwindDataContext().OrdersViews.ToList(); int id = 100; for (int i = 1; i < 9; i++) { tab.Add(new Table1() { Id = id+1, Email = "dbakj@abc.com", Nachname = "bjask", Personalnummer = "bjsak", Status = true, Vorname = "dbaksj" }); . . . id += 6; } List<Table2> table = new List<Table2>(); //Status as foreignkey table.Add(new Table2() { Status = false, anzeige = "chjay", FirstName = "cvusxh" }); . . . ViewBag.datasource = tab; return View(); } |
<script> ej.Grid.Locale["de-DE"] = { True: "true", False: "false" } </script> |
<script> //actionBegin event of the Grid function onBegin(args) { if (args.requestType == "save") { var dropObj = $("#GridVerified").ejDropDownList("instance"); args.data.Verified = dropObj.getSelectedValue();//set the column value based on dropdown selected value } } </script> |