<script type="text/javascript"> function writeCountry(args) { args.element.ejDropDownList({ width: "100%", dataSource: cooData, allowGrouping: true, fields: { text: "ShipCountry", value: "CountryCode", category: "country" }, value: args.rowdata !== undefined ? args.rowdata["ShipCountry"] : "", select: "select" //binding the select event of the dropdownlist to select function }); } function select(args) { alert(args.value); //get the dropdown list selected value }
</script> |
<div style="margin-top:30px"> @(Html.EJ().Grid<object>("Grid") . . . . . .Columns(col => { col.Field("OrderID").IsPrimaryKey(true).Add(); col.Field("CusID").HeaderText("CustomerID").TextAlign(TextAlign.Left).Add();//CusID field is not present in grid dataSource . . . . }) .ClientSideEvents(eve=>eve.ActionBegin("begin")) ) </div>
<script type="text/javascript"> function begin(args) { if (args.requestType == "save") alert($("#GridCusID").val());//Grid – Grid id, CusID - FieldName }
</script> |
<div style="margin-top:30px"> @(Html.EJ().Grid<object>("Grid") . . . . .Columns(col => { . . . . . col.Field("EmpID").HeaderText("Employee ID").Template("1").Add();//the content rendered within the column will be 1 for all rows . . . . }) ) |
function begin(args) { if (args.requestType == "save") { var record = args.data;
var obj = {}; obj.value = record; obj.GridTNumber = $("#GridCusID").val(); obj.ReceiptType = $("#GridEmpID").val();
args.cancel = false; $.ajax({ url: "/Home/Update", type: "POST", contentType: "application/json", data: JSON.stringify(obj), success: function (data) { alert('Update Success'); }, error: function (e) { args.cancel = true; } }); } public ActionResult Update(EditableOrder value, string GridTNumber, string ReceiptType) |
<div style="margin-top:30px"> @(Html.EJ().Grid<object>("Grid") . . . . .Columns(col => { . . . . col.Field("EmpID").HeaderText("Employee ID").Add(); . . . . . }) .ClientSideEvents(eve=>eve.ActionBegin("begin").Load("load")) ) </div>
<script type="text/javascript">
function load(args) { for (var i = 0; i < this.model.dataSource.length; i++) this.model.dataSource[i].EmpID = 1; }
</script> |