@(Html.EJ().Grid<MVCSampleBrowser.Models.EditableOrder>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
------------------------------
.AllowPaging()
.Columns(col =>
{
col.Field("Verified").HeaderText("Verified").EditType(EditingType.Boolean).TextAlign(TextAlign.Center).Width(110).Add();
col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(100).Priority(4).EditType(EditingType.DateTimePicker).Format("{0:MM/dd/yyyy hh:mm:ss}").ValidationRules(v => v.AddRule("date", true)).Add();
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
})
.ClientSideEvents(eve => eve.ActionComplete("complete"))
)
<script type="text/javascript">
var datetime, grid, value;
function complete(args) {
if (args.requestType == "beginedit") {
var row = this.getRowByIndex(args.rowIndex);
row.find(".e-checkbox").ejCheckBox({ "change": checkChange });
datetime = row.find(".e-datetimepicker").ejDateTimePicker("instance");
value = datetime.model.value;
if (!ej.isNullOrUndefined(row.find(".e-checkbox").attr("checked"))) {
datetime.setCurrentDateTime();
}
}
function checkChange(args) {
grid = $("#FlatGrid").ejGrid("instance");
if (args.isChecked) {
datetime = grid.element.find(".gridform").find(".e-datetimepicker").ejDateTimePicker("instance");
datetime.setCurrentDateTime();
}
else {
datetime.option('value', value);
}
}
}
</script>
|
@(Html.EJ().Grid<MVCSampleBrowser.Models.EditableOrder>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
----------------------------------
.AllowPaging()
.Columns(col =>
{
---------------------
.ClientSideEvents(eve => eve.DataBound("create").ActionComplete("complete"))
)
<script type="text/javascript">
var datetime, grid, value, datetime2, value2;
function complete(args) {
if (args.requestType == "beginedit") {
var row = this.getRowByIndex(args.rowIndex);
var checkbox = row.find(".e-checkbox");
for (var i = 0 ; i < checkbox.length ; i++) {
if ($(row.find(".e-checkbox")[i]).attr("name") == "Verified") {
var check = $(row.find(".e-checkbox")[i]);
check.ejCheckBox({ "change": checkChange });
if ($(row.find(".e-datetimepicker")[i]).attr("name") == "OrderDate") {
datetime = $(row.find(".e-datetimepicker")[i]).ejDateTimePicker("instance");
value = datetime.model.value;
}
if(!ej.isNullOrUndefined($(row.find(".e-checkbox")[i]).attr("checked")))
datetime.setCurrentDateTime();
}
else {
var check2 = $(row.find(".e-checkbox")[i]);
check2.ejCheckBox({ "change": checkChange2 });
datetime2 = $(row.find(".e-datetimepicker")[i]).ejDateTimePicker("instance");
value2 = datetime2.model.value;
if (!ej.isNullOrUndefined($(row.find(".e-checkbox")[i]).attr("checked")))
datetime2.setCurrentDateTime();
}
}
}
function checkChange(args) {
grid = $("#FlatGrid").ejGrid("instance");
if (args.isChecked) {
datetime.setCurrentDateTime();
}
else {
datetime.option('value', value);
}
}
function checkChange2(args) {
grid = $("#FlatGrid").ejGrid("instance");
if (args.isChecked) {
datetime2.setCurrentDateTime();
}
else {
datetime2.option('value', value2);
}
}
}
</script>
|