GridFeatures.cshtml @(Html.EJ().Grid<object>("FlatGrid") .Datasource(ds => ds.URL(Url.Action("/DataSource")).UpdateURL(Url.Action("/DialogUpdate")).InsertURL(Url.Action("/DialogInsert")).RemoveURL(Url.Action("/DialogDelete")).Adaptor(AdaptorType.UrlAdaptor)) .AllowScrolling() .AllowPaging() /*Paging Enabled*/ .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"); }) .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).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Width(90).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(90).EditType(EditingType.Dropdown).Add(); col.Field("ShipCity").HeaderText("Ship City").Width(90).EditType(EditingType.Dropdown).Add(); }).ClientSideEvents(eve=>eve.ActionComplete("complete"))) <script type="text/template" id="template"> <b>Order Details</b> <div id="defaultTab" style="width: 500px;height:300px;"> <ul> <li><a rel='nofollow' href="#tab1">Tab1</a></li> <li><a rel='nofollow' href="#tab2">Tab2</a></li> </ul> <div id="tab1" width="200px"> <img src="../Content/ej/web/common-images/6.png" /> </div> <div id="tab2"> <table cellspacing="10"> <tr> <td style="text-align: right;"> Order ID </td> <td style="text-align: left"> <input id="OrderID" name="OrderID" value="{{: OrderID}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable" style="text-align: right; width: 116px; height: 28px" /> </td> </tr> <tr> <td style="text-align: right;"> Customer ID </td> <td style="text-align: left"> <span class="txt">Select Group</span> <input id="CustomerID" type="text" /> </td> </tr> <tr> <td style="text-align: right;"> Ship City </td> <td style="text-align: left"> <span class="txt">Select Country</span> <input id="ShipCity" type="text" /> </td> </tr> </table> </div> </div> </script> <script type="text/javascript"> function complete(args) { if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialogtemplate") { $("#defaultTab").ejTab({ selectedItemIndex: 0 }); var groups = [ { parentId: 'a', text: "Group A" }, { parentId: 'b', text: "Group B" }, { parentId: 'c', text: "Group C" }, { parentId: 'd', text: "Group D" }, { parentId: 'e', text: "Group E" }] //first level child var countries = [{ value: "Algeria", parentId: 'a', text: "Algeria", sprite: "flag-dz" }, { value: "Armenia", parentId: 'a', text: "Armenia", sprite: "flag-am" }, …. { value: "Ukraine", parentId: 'e', text: "Ukraine", sprite: "flag-ua" }] $('#CustomerID').ejDropDownList({ dataSource: groups, fields: { value: "parentId", text: "text" }, cascadeTo: 'ShipCity', change: "onChange", width: "100%" }); $('#ShipCity').ejDropDownList({ dataSource: countries, width: "100%" }); if (args.requestType == "beginedit") { $("#OrderID").attr("disabled", "disabled"); } } } function onChange() { var ctry = $('#ShipCity').data("ejDropDownList"); ctry.element.val(""); } public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm) { var DataSource = OrderRepository.GetAllRecords(); DataResult result = new DataResult(); result.result = DataSource.Skip(dm.Skip).Take(dm.Take).ToList(); result.count = DataSource.Count(); return Json(result, JsonRequestBehavior.AllowGet); } public class DataResult { public IEnumerable result { get; set; } public int count { get; set; } }
public ActionResult DialogUpdate(EditableOrder value) { OrderRepository.Update(value); var data = OrderRepository.GetAllRecords(); return Json(value, JsonRequestBehavior.AllowGet); }
public ActionResult DialogInsert(EditableOrder value) { OrderRepository.Add(value); var data = OrderRepository.GetAllRecords(); return Json(value, JsonRequestBehavior.AllowGet); }
public ActionResult DialogDelete(int key) { OrderRepository.Delete(key); var data = OrderRepository.GetAllRecords(); return Json(data, JsonRequestBehavior.AllowGet); |
<script type="text/template" id="template"> <b>Order Details</b> <div id="defaultTab" style="width: 500px;height:300px;"> <ul> <li><a rel='nofollow' href="#tab1">Tab1</a></li> <li><a rel='nofollow' href="#tab2">Tab2</a></li> </ul> <div id="tab1" width="200px"> @*Do your tab1 operations here*@ <img src="../Content/ej/web/common-images/6.png" /> </div> <div id="tab2"> @*Do your tab2 operations here*@ <table cellspacing="10"> <tr> <td style="text-align: right;"> Order ID </td> <td style="text-align: left"> <input id="OrderID" name="OrderID" value="{{: OrderID}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable" style="text-align: right; width: 116px; height: 28px" /> </td> </tr> <tr> <td style="text-align: right;"> Customer ID </td> <td style="text-align: left"> <span class="txt">Select Group</span> <input id="CustomerID" type="text" /> </td> </tr> <tr> <td style="text-align: right;"> Ship City </td> <td style="text-align: left"> <span class="txt">Select Country</span> <input id="ShipCity" type="text" /> </td> </tr> </table> </div> </div> <script type="text/javascript"> function complete(args) { if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialogtemplate") { $("#defaultTab").ejTab({ selectedItemIndex: 0 }); … } } |
Hi Gustavo,
We are happy that the provided suggestion helped you.
Please get back to us if you need any further assistance.
Regards,
Jayaprakash K.