@(Html.EJ().Button("ClickMe").Text("Click Me").Type(ButtonType.Button).ClientSideEvents(events=>events.Click("click")))
@(Html.EJ().Grid<object>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.dataSource) .. . . .ClientSideEvents(events=>events.Load("load")) )
<script> function load(args) { this.model.columns.push({ field: "ShipName", headerText: "Ship Name" }); this.model.columns.push({ field: "EmployeeID", headerText: "Employee ID" }); } function click(args) {//update grid columns using columns() var obj = $("#FlatGrid").ejGrid("instance"); obj.columns("CustomerID", "add");//Add column obj.columns("CustomerID", "remove");//remove column obj.columns([{ field: "ShipCity", headerText: "ShipCity" }])//Add an array of object } |
@(Html.EJ().Grid<object>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.dataSource) .. . .. .Columns(ViewBag.cols) //use the columns ViewBag namespace MvcApplication66.Controllers { public class HomeController : Controller { public ActionResult Index() { ViewBag.dataSource = OrderRepository.GetAllRecords(); List<Column> cols = new List<Column>();// Column is a class of Syncfusion Javascript models cols.Add(new Column() { Field = "OrderID", HeaderText = "Order ID"});//Add some column ViewBag.cols = cols; //update them in ViewBag return View(); } } |