<script type="text/javascript"> $(function () {// Document is ready. $("#Grid").ejGrid({ ... columns: [ { field: "OrderID", headerText: "Order ID", width: 100, isPrimaryKey: true }, { field: "Verified", width: 100, editType: ej.Grid.EditingType.Boolean }//checkbox column ], actionBegin: "begin" }); }); </script> <script> function begin(args) { //triggers for every grid action if (args.requestType == "save") { //calls when the requestType is save (i.e clicking save button in toolbar) if ($("#GridVerified").is(":checked") != true) { //when saving if the checkbox is not checked. args.cancel = true; toastr.error('change the checkbox to true', 'validation fails'); var grid = $("#Grid").ejGrid("instance"); var inputelement = grid.element.find("form").find('.e-checkbox'); $(inputelement).focus(); } else //if checkbox is checked shown success toastr message toastr.success('Validation succeeded and data saved'); } } $(function (c) { $(document).on("change", "#GridVerified", function (c) { //triggers when changing the checkbox value if (c.target.checked == true) { toastr.success('CheckBox value changed'); } }); }); </script> |
<link rel='nofollow' href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/css/toastr.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.js"></script> |