@(Html.EJ().Grid<object>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowSorting() .AllowPaging() .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); }); }) .ClientSideEvents(eve => eve.ToolbarClick("complete")) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Visible(false).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Visible(false).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Visible(false).Format("{0:C}").Add(); col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Visible(false).Format("{0:MM/dd/yyyy}").Add(); col.Field("ShipCity").HeaderText("Ship City").Width(110).Visible(false).Add(); }) )
<script> function complete(args) { if (args.itemName == "Edit") { var grid = $("#Grid").ejGrid("instance"); var index = parseInt(grid.selectedRowsIndexes[0]); $('#Grid').data("ejGrid").showColumns(["ShipCity", "Freight"]); grid.selectRows(index); } </script> |
@(Html.EJ().Grid<object>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowSorting() .AllowPaging() .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); }); }) .ClientSideEvents(eve => eve.ToolbarClick("complete").RecordDoubleClick("edit")) .Columns(col => { ….
}) )
<script> function complete(args) { if (args.itemName == "Edit") { var grid = $("#FlatGrid").ejGrid("instance"); var index = parseInt(grid.selectedRowsIndexes[0]); $("#FlatGrid").data("ejGrid").showColumns(["ShipCity", "Freight"]); grid.selectRows(index); } } function edit(args) { if (!this.columnPushed) { $("#FlatGrid").data("ejGrid").showColumns(["ShipCity", "Freight"]); this.columnPushed = true;// checking if columns are already pushed this.startEdit($(this.getContentTable().find("tr")[args.rowIndex])); } } </script> |