@(Html.EJ().Grid<OrdersView>("Editing")
.AllowPaging()
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width(90).Add();
col.Field("CustomerID").HeaderText("Customer ID"). Add();
col.Field("Freight").HeaderText("Freight")..Format("{0:C}").Add();
col.Field("EmployeeID").HeaderText("Employee ID").Width(85).Add();
})
.ClientSideEvents(events =>
{
events.ActionComplete("complete");
})
)
<script id="template" type="text/template">
<b>Order Details</b>
<table cellspacing="10">
. .
. .
<tr>
<td style="text-align: right;">
Employee ID
</td>
<td style="text-align: left">
<input type="text" id="EmployeeID" name="EmployeeID" value="{{:EmployeeID}}" />
</td>
</tr>
</table>
</script>
<script>
var cLocs = @Html.Raw(Json.Encode(@ViewBag.data));
function complete(args) {
if (args.requestType == "beginedit" || args.requestType == "add") {
$("#Freight").ejNumericTextbox({ value: parseFloat($("#Freight").val()), width: "116px", decimalPlaces: 2 });
$("#EmployeeID").ejDropDownList({ width: '116px', dataSource: cLocs, fields: { value: "EmployeeID", text: "FirstName" } });
if (args.requestType == "beginedit") {
$("#OrderID").attr("disabled", "disabled");
$("#EmployeeID").ejDropDownList("setSelectedValue", args.row.children().eq(3).text());
}
$(".e-field").css({ 'width': '116px', 'text-align': 'left' });
}
}
</script> |