@(Html.EJ().Grid<object>("StackedHeaderGrid")
.Datasource(datasource => datasource.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Home/Update")
.InsertURL("/Home/Insert").RemoveURL("/Home/Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.ClientSideEvents(eve => { eve.ActionComplete("complete"); })
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"); })
--------
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("EmployeeID").HeaderText("EmployeeID").Width(80).Add();
col.Field("CustomerID").HeaderText("CustomerID").TextAlign(TextAlign.Right).Width(80).Add();
col.Field("ShipCity").HeaderText("Ship City").Width(110).Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width(110).Add();
}))
<script id="template" type="text/template">
<table cellspacing="10">
<tr>
<td>Order ID</td>
<td>
<input id="OrderID" name="OrderID" disabled="disabled" value="{{:OrderID}}" class="e-field e-ejinputtext" style="width:116px;height:28px" />
</td>
<td>Customer ID</td>
<td>
<input id="CustomerID" name="CustomerID" value="{{:CustomerID}}" class="e-field e-ejinputtext" style="width: 116px; height: 28px" />
</td>
</tr>
<tr>
<td>Employee ID</td>
<td>
<input type="text" id="EmployeeID" name="EmployeeID" value="{{:EmployeeID}}" />
</td>
<td>Ship City</td>
<td>
<input type="text" id="ShipCity" name="ShipCity" value="{{:ShipCity}}" />
</td>
</tr>
</table>
</script>
<script>
function complete(args) {
var dataManagerEmp = ej.DataManager({
url: "/Home/Employee",
adaptor: new ej.UrlAdaptor()
});
var dataManagerCust = ej.DataManager({
url: "/Home/Customer",
adaptor: new ej.UrlAdaptor()
});
var dataManagerCity = ej.DataManager({
url: "/Home/City",
adaptor: new ej.UrlAdaptor()
});
if (args.requestType == "beginedit") {
$("#EmployeeID").ejDropDownList({
dataSource: dataManagerEmp,
fields: { text: "EmployeeID", value: "EmployeeID" },
});
$("#CustomerID").ejDropDownList({
dataSource: dataManagerCust,
fields: { text: "CustomerID", value: "CustomerID" },
});
$("#ShipCity").ejDropDownList({
dataSource: dataManagerCity,
fields: { text: "ShipCity", value: "ShipCity" },
});
}
}
</script> |