|
<ejs-grid id="Grid" dataSource="ViewBag.dataSource" toolbar="@(new List<string>() { "Update","Cancel" })" allowPaging="true" cellSave="cellSave">
<e-grid-editSettings allowAdding="false" allowDeleting="false" allowEditing="true" mode="Batch"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" validationRules="@(new { required=true, number=true})" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" validationRules="@(new { required=true})" textAlign="Right" editType="numericedit" format="C2" width="120"></e-grid-column>
<e-grid-column field="OrderDate" headerText="Order Date" editType="datepickeredit" format="yMd" width="170"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" editType="dropdownedit" width="150"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
<e-grid-column field="Verified" headerText="Verified" displayAsCheckBox="true" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function cellSave(args) {
var grid = document.getElementById("Grid").ej2_instances[0]; //Grid instances if (args.columnName == "CustomerID") {
// Updates particular cell value by passing primary key value, column field, new value as parameter to the setCellValue method of Grid.
if (args.value.length > 0) {
grid.setCellValue(args.rowData.OrderID, "Verified", true)
} else {
grid.setCellValue(args.rowData.OrderID, "Verified", false)
}
}
}
</script> |