@(Html.EJ().Grid<object>("Editing")
.Datasource((IEnumerable<object>)ViewBag.dataSource)
.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("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("ShipCountry").HeaderText("Ship Country").EditType(EditingType.Dropdown).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(90).Add();
})
)
------------------------------------------------------------------
<script type="text/template" id="template">
<b>Order Details</b>
<table cellspacing="10">
--------------------------------------
<td style="text-align: right;">Ship Name
</td>
<td style="text-align: left">
<input id="ShipName" name="ShipName" value="{{: ShipName}}" class="e-field e-ejinputtext valid"
style="width: 116px; height: 28px" />
</td>
</tr>
<tr>
<td style="text-align: right;">Ship Address
</td>
<td style="text-align: left">
<textarea id="ShipAddress" name="ShipAddress" class="e-ejinputtext" value="{{: ShipAddress}}">{{: ShipAddress}}</textarea>
</td>
</tr>
</table>
</script>
|
@(Html.EJ().Grid<EJGrid.Models.EmployeeView>("Editing")
.Datasource((IEnumerable<object>)ViewBag.dataSource)
.EditSettings(edit => edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"))
-------------------------------
.AllowPaging()
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).Add();
col.Field("EmployeeID").HeaderText("Employee ID").Width(80).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("Freight").HeaderText("Freight").Width(80).Add();
})
)
@Html.Partial("EditTemplate")
--------------------------------------------------------------------
$.ajax({
url: "/Home/GetData",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ value: records }),
success: function (data) {
$("#template").html(data);
args.model.prefixIcon != "create" && $("#OrderID").attr("disabled", "disabled");
$($("#template").html()).prependTo($("#GridEditForm"));
//ej.widget.init($("#template")); //initialize the ejwidgets
},
error: function (xhr) {
alert('error');
}
});
} |
@(Html.EJ().Grid<object>("Grid")
.Datasource((IEnumerable<object>)ViewBag.data)
.AllowPaging()
---------------------------------------
.EditSettings(edit =>
{
edit.AllowAdding();//enebled adding
edit.AllowDeleting();//enabled deleting
edit.AllowEditing();//enabled editing
edit.EditMode(EditMode.DialogTemplate);//setting edit mode as dialog such as dialog open on add/edit
})
.Columns(col =>
{
-------------------------
})
.ClientSideEvents(eve => eve.ActionComplete("complete"))
)
--------------------------------------------------------------------
$.ajax({
url: "/Home/GetData",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ value: records }),
success: function (data) {
$("#template").html(data);
args.model.prefixIcon != "create" && $("#OrderID").attr("disabled", "disabled");
$($("#template").html()).prependTo($("#GridEditForm"));
//ej.widget.init($("#template")); //initialize the ejwidgets
},
error: function (xhr) {
alert('error');
}
});
} |