@(Html.EJ().Grid<SyncfusionMvcApplication58.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowScrolling() .AllowPaging() /*Paging Enabled*/ .SelectionType(SelectionType.Single) .ContextMenuSettings(contextMenu => {
contextMenu.EnableContextMenu().CustomContextMenuItems(new List<string>() { "PrimaryKey" });
}) .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("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.Field("ShipCity").HeaderText("Ship City").Width(110).Add(); col.Field("ShipName").HeaderText("Ship Name").Width(170).Add(); }).ClientSideEvents(eve => { eve.ContextClick("contextclick"); })) <script type="text/javascript"> function contextclick (args) { if (args.text == "PrimaryKey") { var primaryKeyValue = this.getSelectedRecords()[0].OrderID; alert("primaryKeyValue->" + primaryKeyValue);//you can perform own action here } } |
@(Html.EJ().Grid<SyncfusionMvcApplication58.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowScrolling() .AllowPaging() /*Paging Enabled*/ .SelectionType(SelectionType.Single) .ContextMenuSettings(contextMenu => {
contextMenu.EnableContextMenu().CustomContextMenuItems(new List<string>() { "PrimaryKey" });
}) .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("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.Field("ShipCity").HeaderText("Ship City").Width(110).Add(); col.Field("ShipName").HeaderText("Ship Name").Width(170).Add(); }).ClientSideEvents(eve => { eve.ContextClick("contextclick").RightClick("rightclick").ContextOpen("contextopen"); })) <script type="text/javascript"> function contextclick (args) { if (args.text == "PrimaryKey") { var primaryKeyValue = this.getSelectedRecords()[0].OrderID; alert("primaryKeyValue->" + primaryKeyValue);//you can perform own action here } } function contextopen(args) { if ($(args.target).hasClass("e-headercelldiv") || $(args.target).hasClass("e-pager")) $("#FlatGrid_Context").find(".e-customitem").hide(); //Gridid_Context else $("#FlatGrid_Context").find(".e-customitem").show(); |