<script> var dmAdaptorUpdate = function (keyField, value, tableName) { var res = this.adaptor.update(this, keyField, value, tableName); return $.ajax($.extend({ beforeSend: ej.proxy(this._beforeSend, this) }, res)); } var dmAdaptorInsert = function (data, tableName) { var res = this.adaptor.insert(this, data, tableName); var deffer = $.Deferred(); $.ajax($.extend({ beforeSend: ej.proxy(this._beforeSend, this), success: ej.proxy(function (record, status, xhr, request) { record = function () { if (data.d) data = data.d; return data; }; deffer.resolveWith(this, [{ record: record, dataManager: this }]); }, this), error: function (e) { deffer.rejectWith(this, [{ error: e, dataManager: this }]); } }, res));
return deffer.promise(); } var adaptor = new ej.UrlAdaptor().extend({ update: function (dm, keyField, value, tableName) { var token = value.__RequestVerificationToken; delete value['__RequestVerificationToken']; return { type: "POST", url: dm.dataSource.updateUrl || dm.dataSource.crudUrl || dm.dataSource.url, data: { __RequestVerificationToken: token, value: value } }; }, insert: function (dm, data, tableName) { var token = value.__RequestVerificationToken; delete data['__RequestVerificationToken']; return { type: "POST", url: dm.dataSource.insertUrl || dm.dataSource.crudUrl || dm.dataSource.url, data: { __RequestVerificationToken: token, value: data } }; } })
function load(args) { this.model.dataSource.adaptor = new adaptor(); this.model.dataSource.update = dmAdaptorUpdate; this.model.dataSource.insert = dmAdaptorInsert; } <script type="text/template" id="template"> <b>Order Details</b> @Html.AntiForgeryToken() <table cellspacing="10"> . . . . </table> [HttpPost] [ValidateAntiForgeryToken] public ActionResult Update(EmployeeView value) { OrderRepository.Update(value); var data = OrderRepository.GetAllRecords2(); return Json(value, JsonRequestBehavior.AllowGet); } [ValidateAntiForgeryToken] public ActionResult Insert(EmployeeView value) { OrderRepository.Add(value); var data = OrderRepository.GetAllRecords2(); return Json(data, JsonRequestBehavior.AllowGet); |
Queries |
Response | |
How do I change the dialog title using a JS function? |
We found that you have not get the proper ID for the dialogBox. In dialog mode, the dialog box id will generate with the grid id. So, we suggest to you to use the proper id in the following manner. Please find the code example, screenshot and sample:
Screenshot : Sample: http://www.syncfusion.com/downloads/support/forum/121647/ze/EJGrid673211952 | |
Can I use my own bootstrap form styling css? |
Yes, you can use the bootstrap form elements in the template. Please find the code example and sample:
|
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).Adaptor(AdaptorType.RemoteSaveAdaptor).UpdateURL("/Home/Update").InsertURL("/Home/Insert").RemoveURL("/Home/Remove"))
.EditSettings(edit => edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"))
---------------------------
|