hiii to all, i am using jqgrid, and want to display error message if the user wants to delete the truck record which is in use, i have to display a error message truck in use..
here is my jqgrid:-
jQuery(document).ready(function () {
var grid = jQuery("#TrucksGrid141");
grid.jqGrid({
url: '/Admin/GetTrucksForJQGrid',
datatype: 'json',
mtype: 'Post',
cellsubmit: 'remote',
cellurl: '/Admin/SaveTruck',
height: '100%',
pager: '#pagerTrucks',
colNames: ['Id', 'Name', ''],
colModel: [
{ name: 'Id', index: 'Id', key: true, hidden: true, editrules: { edithidden: true } },
{ name: 'Name', index: 'Name', align: "center", sorttype: 'text', resizable: true, editable: true, editrules: { required: true } },
{ name: 'Delete', index: 'Delete', width: 25, resizable: false, align: 'center', classes: 'not-editable-cell' }
],
width: '490',
caption: 'Company Trucks',
hidegrid: false,
delete: true,
cellEdit: true,
viewrecords: true,
gridComplete: function () {
var ids = grid.jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var isDeleted = grid.jqGrid('getCell', ids[i], 'Delete');
if (isDeleted != 'true') {
grid.jqGrid('setCell', ids[i], 'Delete', '<img src="/Images/delete.png" alt="Delete Row" />');
}
else {
grid.jqGrid('setCell', ids[i], 'Delete', ' ');
//grid.jqGrid('setCell', ids[i], 'Privileges', 'admin');
}
}
}
}
);
grid.jqGrid('navGrid', '#pagerTrucks',
{ resize: false, add: false,search:false, del: false, refresh: false, edit: false, alerttext: 'Please select one user' }
).jqGrid('navButtonAdd', '#pagerTrucks',
{ title: "Add New Truck", buttonicon: "ui-icon ui-icon-plus", onClickButton: showNewTruckModal, position: "First", caption: "" });
});
function showNewTruckModal() {
var grid = jQuery("#TrucksGrid141");
$("#formAddNewTruck").dialog(
{
open: function (event, ui) {
$("#txtName").val('');
$("#trFormErrorTrucks").hide();
$("#trFormErrorTrucks td").text('');
},
buttons: {
"Submit": function () {
debugger;
if (ValidateUsers() == true) {
$('#error').ajaxError(function (event, request, settings) {
$('#waiting').hide();
$(this).addClass('errordiv').text(request.statusText + "" + request.status);
});
$.post('/Admin/AddNewTruck/',
$('#formAddNewTruck').serialize(),
function (data) {
debugger;
if (data == 'Success') {
$('#formAddNewTruck').dialog("close");
grid.jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
}
else {
$("#trFormErrorTrucks").show();
$("#trFormErrorTrucks td").text(data);
}
});
}
},
"Cancel": function () {
$('#error').removeClass("errordiv").text("");
$('#waiting').hide();
$(this).dialog("close");
}
},
modal: true,
title: "New Truck",
minWidth: 400,
resizable: false
}
).dialog('open');
}
function ValidateUsers() {
var flag = true;
var errorMSG = '';
$("#trFormErrorTrucks td").text('');
if ($("#txtName").val() == '') {
errorMSG += 'Truck Name cannot be blank';
flag = false;
}
if (flag == false) {
$("#trFormErrorTrucks").show();
$("#trFormErrorTrucks td").text(errorMSG);
}
else {
$("#trFormErrorTrucks td").text('');
$("#trFormErrorTrucks").hide();
}
return flag;
}
function deleteRow(rowid) {
jQuery("#TrucksGrid141").delGridRow(rowid, { url: '/Admin/TruckDelete', caption: 'Delete User?', msg: 'Delete selected User? <br />Careful, this is irreversable!', resize: false,success:abc });
}
function emptyText(rowid, cellname, value, iRow, iCol) {
if (cellname == 'Password')
return "";
}
function abc(data)
{
debugger;
}
and here is my cs code from controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult TruckDelete(int Id)
{
var error = "";
bool result=true;
DataContext db = new DataContext();
Truck udelete= db.Trucks.Where(el => el.Id == Id).FirstOrDefault();
if (udelete != null)
{
JobSites_ForSnow snow = db.JobSites_ForSnow.Where(el => el.TruckId == Id).FirstOrDefault();
JobSite normal = db.JobSites.Where(el => el.TruckId == Id).FirstOrDefault();
if(snow==null && normal==null)
{
db.Trucks.Remove(udelete);
db.SaveChanges();
}
else
{
error = "Truck in use!";
result= false;
}
}
else
{
error = "Record Not Found!";
result= false;
}
return Json(result,error);
}
can anybody tell me how can i display the error message? i have seen this answer (jqgrid error message on delete) but didn't understood what to do :(. if the question is not clear to you, please let me know by comment, i will explain ...thanks in advance :)
You use currently
return Json(result,error);
as the last line of TruckDelete action, where result have boolean type and error is a string. So the Controller.Json Method (Object, String) where error will be interpreted as contentType of HTTP response. It's your first problem. You should use probably something like
return Json(new Object[] {result, error});
(see here). In the case the method will generate JSON response like
[true,""]
or
[false,"Record Not Found!"]
The client side (jqGrid) can process the response inside of afterSubmit callback. You need just replace unknown (for jqGrid) option success of delGridRow to the following
jQuery("#TrucksGrid141").delGridRow(rowid, {
url: '/Admin/TruckDelete',
caption: 'Delete User?',
msg: 'Delete selected User? <br />Careful, this is irreversable!',
resize: false,
afterSubmit: function (jqXHR) {
return $.parseJSON(jqXHR.responseText); // return decoded response
}
});
Related
i have problem to return two parameters result from return json in c# .net 5 to ajax. where the return result cannot be read in ajax
i have html code
<button id="DELETE" onclick="ConfirmDelete(#item.Id)" class="btn btn-danger btn-sm">Delete</button>
jquery code
function ConfirmDelete(id) {
Swal.fire({
icon:'question',
title: 'are you sure delete it?',
showCancelButton: true,
confirmButtonText: 'Ya',
confirmButtonColor: '#d33',
cancelButtonText: 'Tidak'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: 'POST',
url: '#Url.Content("Latihan/Delete")',
data: { Id: id },
dataType: "json",
success: function (data) {
if (data.Isuccess == true) {
Swal.fire({
icon: 'success',
title: 'Delete Success',
text: '',
confirmButtonText: 'Ok'
}).then((result) => {
if (result.isConfirmed) {
location.reload();
}
});
}
else {
Swal.fire({
icon: 'error',
title: 'Error Found',
text: data,
confirmButtonText: 'Ok'
}).then((result) => {
if (result.isConfirmed) {
location.reload();
}
});
}
},
error: function (data) {
Swal.fire({
icon: 'error',
title: 'Unknown Error',
text: 'Delete Failed',
confirmButtonText: 'Ok'
}).then((result) => {
if (result.isConfirmed) {
location.reload();
}
});
}
});
}
})
};
controller
[HttpPost]
public async Task<JsonResult> Delete(int? id)
{
List<string> msgerror = new List<string>();
bool result = false;
try
{
if (id == null || id < 0)
{
msgerror.Add("Data cannot be null");
}
else
{
var LatihanDelete = await _context.TB_BIODATA.FirstOrDefaultAsync(e => e.Id == id);
if (LatihanDelete == null)
{
msgerror.Add("Data not found");
}
else
{
//_context.TB_BIODATA.Remove(LatihanDelete);
//await _context.SaveChangesAsync();
result = true;
}
}
}
catch (Exception e)
{
msgerror.Add("Error Exception : " + e.Message);
}
return Json(new{Isuccess = result, MessageError = msgerror});
}
but if I pass only one parameter, then the return result can be read fine in ajax
controller
return Json("Success");
jquery code
success: function (data) {
if (data == "Success") {
Swal.fire({
icon: 'success',
title: 'Delete Success',
text: '',
confirmButtonText: 'Ok'
}).then((result) => {
if (result.isConfirmed) {
location.reload();
}
});
}
can anyone help why this is different, and what should i fix? thank you
try this
return new JsonResult( new {IsSuccess = result, MessageError = msgerror} );
I have Kendo Grid in my view. I have specified read , edit and delete each as of type HTTPPOST. But when I try to edit or delete i get an error that : "A public action method 'UpdateDetails' was not found on controller 'Nop.Plugin.Misc.CategoryWiseShipping.Controllers.ShippingChargeController'." for update Action and similarly one other for delete option.
Interesting thing is that it works fine on my local machine but throws error when published to server
I have searched extensivelly on google but couldn't find the reason as to why it is happening.
This is the controller actionMethod
[HttpPost]
public ActionResult UpdateDetails(ShippingChargeModel shippingChargeModel)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
return AccessDeniedView();
if (shippingChargeModel.SchoolEmail == null)
{
ErrorNotification(" Email can not be null !!", true);
return RedirectToAction("AddShippingCharge", "ShippingCharge");
}
if (shippingChargeModel.SaleStartDate == null)
{
ErrorNotification(" Sale start date can not be null !!", true);
return RedirectToAction("AddShippingCharge", "ShippingCharge");
}
if (shippingChargeModel.SaleEndDate == null)
{
ErrorNotification(" Sale end date can not be null !!", true);
return RedirectToAction("AddShippingCharge", "ShippingCharge");
}
if (shippingChargeModel.SaleEndDate < shippingChargeModel.SaleStartDate)
{
ErrorNotification(" Sale start date should be less than sale end date!!", true);
return RedirectToAction("AddShippingCharge", "ShippingCharge");
}
var modelFromDb = _catShippingService.GetRecord(shippingChargeModel.Id);
modelFromDb.SaleEndDate = shippingChargeModel.SaleEndDate.Value.AddMinutes(330);
modelFromDb.SaleStartDate = shippingChargeModel.SaleStartDate.Value.AddMinutes(330);
modelFromDb.SchoolEmail = shippingChargeModel.SchoolEmail;
modelFromDb.ShippingCharge = shippingChargeModel.ShippingCharge;
modelFromDb.ModifyDate = DateTime.Now;
_catShippingService.Update(modelFromDb);
return new NullJsonResult();
}
This is my Kendo Grid :
function loadKendo() {
var dataNew = {};
$("#shippingCharge-grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "#Html.Raw(Url.Action("GetDetails", "ShippingCharge"))",
type: "POST",
dataType: "json",
},
update: {
url: "#Html.Raw(Url.Action("UpdateDetails", "ShippingCharge"))",
type: "POST",
dataType: "json",
//data: addAntiForgeryToken
},
destroy: {
url: "#Html.Raw(Url.Action("DeleteDetails", "ShippingCharge"))",
type: "POST",
dataType: "json",
}
,
parameterMap: function (data, operation) {
if (operation === "update") {
dataNew.Id = data.Id;
dataNew.CategoryId = data.CategoryId;
dataNew.ShippingCharge = data.ShippingCharge;
dataNew.SaleStartDate = stringToTimestamp(data.SaleStartDate.toUTCString());
dataNew.SaleEndDate = stringToTimestamp(data.SaleEndDate.toUTCString());
dataNew.SchoolEmail = data.SchoolEmail;
return { ShippingChargeModel: dataNew };
}
return data;
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
//ProductId: { editable: false, type: "number" },
CategoryId: { editable: false, type: "string" },
CategoryName: { editable: false, type: "string" },
ShippingCharge: { editable: true, type: "number" },
SaleStartDate: { editable: true, type: "date", format: "{0:dd/MMM/yyyy HH:mm}"},
SaleEndDate: { editable: true, type: "date", format: "{0:dd/MMM/yyyy HH:mm}"},
SchoolEmail: { editable:true, type: "string" }
}
}
},
requestEnd: function (e) {
if (e.type == "update") {
this.read();
}
if (e.type == "cancel") {
this.cancelChanges();
}
},
error: function (e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
pageable: {
refresh: true,
numeric: false,
previousNext: false,
info: false,
pageSizes: [#(gridPageSizes)]
},
editable: {
confirmation: "#T("Admin.Common.DeleteConfirmation")",
mode: "inline"
},
scrollable: false,
columns: [
{
field: "CategoryName",
title: "CategoryName",
width: 300
},
{
field: "ShippingCharge",
title: "Shipping Charge",
width: 100,
encoded: false
}
,
{
field: "SchoolEmail",
title: "Email",
width: 200,
encoded: false
}
,
{
field: "SaleStartDate",
title: "Sale Start Date",
width: 200,
encoded: false,
type: "datetime",
format: "{0:dd/MMM/yyyy HH:mm}",
template: "#= kendo.toString(kendo.parseDate(SaleStartDate, 'yyyy-MM-dd'), 'dd/MMM/yyyy') #",
editor: dateTimeEditor
},
{
field: "SaleEndDate",
title: "Sale End Date",
width: 200,
encoded: false,
type: "datetime",
format: "{0:dd/MMM/yyyy HH:mm}",
template: "#= kendo.toString(kendo.parseDate(SaleEndDate, 'yyyy-MM-dd'), 'dd/MMM/yyyy') #",
editor: dateTimeEditor
}, {
command: [
{
name: "edit",
text: {
edit: "#T("Admin.Common.Edit")",
update: "#T("Admin.Common.Update")",
cancel: "#T("Admin.Common.Cancel")"
}
}
, {
name: "destroy",
text: "#T("Admin.Common.Delete")"
}
],
width: 200
}
]
});
}
Please help me out. Any sort of insight will do ...
Im updating the grid values from the database. And passing values from CS page to JSgrid. Delete,Edit is perfectly working with db. But after search the grid is not getting updated.I can pass the search value to the CS page and get the corresponding search value from DB. But the values are not getting updated with JSgrid.
var Status;
var lastPrevItem;
var clients =<%=gridData%>
$("#jsGrid").jsGrid({
width: "100%",
height: "450px",
filtering: true,
//filterable:true,
//inserting: true,
autosearch: true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 25,
pageButtonCount: 5,
deleteConfirm: "Do you really want to delete the Department?",
controller: //db,
{ loadData: function (filter) {
if (filter["ID"] != "" || filter["Name"] != "") {
return $.ajax({
type: "POST",
async: true,
processdata: false,
paging: true,
contentType: "application/json; charset=utf-8",
url: "myurl/mycsmethod",
data: "{'ID':'" + filter["ID"] + "','Name':'" + filter["Name"]+ "'}",
success: function (data) {
},
error: function (XHR, errStatus, errorThrown) {
var err = JSON.parse(XHR.responseText);
errorMessage = err.Message;
alert(errorMessage);
}
});
}
},
updateItem: function (clients) {
var result = $.Deferred();
alert(result);
var ajaxDeferred = $.Deferred().reject();
alert(ajaxDeferred);
ajaxDeferred.done(function (updatedItem) {
result.resolve(updatedItem);
}).fail(function () {
result.resolve(lastPrevItem);
});
return result.promise();
},
},
onItemDeleting: function (args) {
//its working fine
},
onItemEditing: function (args) {
//its working fine
},
data: clients,
fields: [
{ type: "control" },
{ name: "ID", visible: false, width: 0, validate: "required" },
{ name: "Name", visible: false, width: 0, validate: "required" },
]
});
I want to update <%=gridData%> with jsgrid once the search button is triggered.
loadData: function(filter) {
return $.grep(clients, function(client) {
return (!filter["DeptID"] || client["DeptID"].indexOf(filter["DeptID"]) > -1)
&& (!filter["DeptName"] || client["DeptName"].indexOf(filter["DeptName"])>-1)
&& (!filter["Status"] || client["Status"].indexOf(filter["Status"]) > -1)
});},
updateItem: function (updatingClient) {
var result = $.Deferred();
alert(result);
var ajaxDeferred = $.Deferred().reject();
alert(ajaxDeferred);
ajaxDeferred.done(function (updatedItem) {
result.resolve(updatedItem);
}).fail(function () {
result.resolve(lastPrevItem);
});
return result.promise();
},
Its working now with the above code,friends.But If anything,i need to improve in my code, please let me know.
I have a kendo grid that is edited inline. One of the fields should be edited selecting an element from a list, but the list must have a hierarchical structure (would be nice be able of filter that list). I was thinking in use a kendo treeview as editor for that field but I haven't found any way to accomplish this. I tried make a custom editor template (using columns.Bound(s => s.FieldId).EditorTemplateName("_TreeEditorTemplate")) that render the treeview, but the treeview is not an input and is not selectable. I also thinked in make an editor that use a kendo dropdownlist with the tree inside but this is no currently supported by kendo. Any ideas???
Have you looked at the sample on the Kendo site: https://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/use-treeview-as-grid-editor
<div id="example">
<div id="grid"></div>
<script>
$(document).ready(function () {
var crudServiceBaseUrl = "//demos.telerik.com/kendo-ui/service",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/Products",
dataType: "jsonp"
},
update: {
url: crudServiceBaseUrl + "/Products/Update",
dataType: "jsonp"
},
destroy: {
url: crudServiceBaseUrl + "/Products/Destroy",
dataType: "jsonp"
},
create: {
url: crudServiceBaseUrl + "/Products/Create",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
UnitPrice: { type: "number", validation: { required: true, min: 1 } },
Discontinued: { type: "boolean" },
UnitsInStock: { type: "number", validation: { min: 0, required: true } }
},
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
edit: function (e) {
//checking if a cell from the Test column is opened for editing
var dummyInput = e.container.find("input[name='test']");
if (dummyInput.length > 0) {
var treeView = $(e.container).find(".treeViewEditor").data("kendoTreeView");
var originalItem = treeView.findByText(dummyInput.val());
if (originalItem != null) {
// Select the item based on the field value
treeView.select(originalItem);
}
}
},
navigatable: true,
pageable: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: [
"ProductName",
{
field: "test", title: "Test", width: 120,
editor: function (container, options) {
var input = $("<input class='tveInput'/>");
input.attr("name", options.field);
var tvDiv = $("<div class='treeViewEditor'></div>");
$(tvDiv).kendoTreeView({
animation: false,
dataSource: [
{
text: "foo1"
},
{
text: "foo2",
items: [
{ text: "bar" },
{ text: "bar1" },
{ text: "bar2" }
]
}
]
});
var treeView = $(tvDiv).data("kendoTreeView");
$(tvDiv).find(".k-in").mousedown(function (e) {
var clickedNode = $(e.toElement).closest("[role=treeitem]");
var dataItem = treeView.dataItem(clickedNode);
var dummyInput = clickedNode.closest("[role=gridcell]").find("input[name='test']");
dummyInput.val(dataItem.text);
dummyInput.trigger("change");
});
tvDiv.appendTo(container);
input.appendTo(container);
}
},
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: 120 },
{ field: "UnitsInStock", title: "Units In Stock", width: 120 },
{ field: "Discontinued", width: 120 },
{ command: "destroy", title: " ", width: 150 }],
editable: true
});
});
</script>
</div>
<style>
.tveInput {
display: none;
}
</style>
Class that carries out CRUD functionality with a help of a stored proc
public class InsertUpdateDeleteBLL
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
SqlCommand com = new SqlCommand();
public string InsertUpdateDeleteMethod(object param)
{
string returnValue = "";
try
{
Dictionary<string,> editData = param as Dictionary<string,>;
com.CommandText = "InsertUpdateDeleteSP";
com.CommandType = CommandType.StoredProcedure;
if (editData["oper"].ToString() == "del")
{
com.Parameters.AddWithValue("#UserID", editData["UserID"] == DBNull.Value ? 0 : editData["UserID"]);
com.Parameters.AddWithValue("#Actiontype", editData["oper"].ToString());
}
else
{
com.Parameters.AddWithValue("#UserID", editData["UserID"] == DBNull.Value ? 0 : editData["UserID"]);
com.Parameters.AddWithValue("#FirstName", editData["FirstName"].ToString());
com.Parameters.AddWithValue("#LastName", editData["LastName"].ToString());
com.Parameters.AddWithValue("#IsActive", editData["IsActive"].ToString());
com.Parameters.AddWithValue("#Department", editData["Department"].ToString());
com.Parameters.AddWithValue("#Email", editData["Email"].ToString());
com.Parameters.AddWithValue("#IsSuperAdmin", editData["IsSuperAdmin"].ToString());
com.Parameters.AddWithValue("#JobRole", editData["JobRole"].ToString());
com.Parameters.AddWithValue("#UserName", editData["UserName"].ToString());
}
com.Connection = conn;
conn.Open();
int m = com.ExecuteNonQuery();
if (m > 0)
{
if (editData["oper"].ToString() == "add")
{
returnValue = "Record Added Successfully";
}
else if (editData["oper"].ToString() == "edit")
{
returnValue = "Record Updated Successfully";
}
else if (editData["oper"].ToString() == "del")
{
returnValue = "Record Deleted Successfully";
}
else
{
throw new Exception("there is problem");
}
}
}
catch (Exception ex)
{
returnValue = ex.Message.ToString();
}
finally
{
conn.Close();
}
return returnValue;
}
//WebMethod
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string EditUpdateDelete(object data)
{
Helper.InsertUpdateDeleteBLL insertUpdateDelete = new Helper.InsertUpdateDeleteBLL();
string returnMessage = insertUpdateDelete.InsertUpdateDeleteMethod(data);
return returnMessage;
}
<script type="text/javascript">
$.ajax({
type: "POST",
contentType: "application/json",
data: "{}",
url: "MyTestPage.aspx/getData",
dataType: "json",
success: function (data) {
data = data.d;
$("#list").jqGrid({
datatype: "local",
colNames: ['UserID', 'First Name', 'Last Name', 'Is Active', 'Department', 'Email', 'Is Super Admin', "Job Role", 'Username'],
colModel: [
{ name: 'UserID', index: 'UserID', width: 50, stype: 'text' },
{ name: 'FirstName', index: 'FirstName', width: 130, stype: 'text', sortable: true, editable: true },
{ name: 'LastName', index: 'LastName', width: 130, editable: true },
{ name: 'IsActive', index: 'IsActive', width: 60, editable: false },
{ name: 'Department', index: 'Department', width: 80, align: "centre", sortable: true, editable: true },
{ name: 'Email', index: 'Email', width: 150, align: "centre", editable: true },
{ name: 'IsSuperAdmin', index: 'IsSuperAdmin', width: 150, align: "middle", editable: true },
{ name: 'JobRole', index: 'JobRole', width: 150, sortable: true, editable: true },
{ name: 'Username', index: 'Username', width: 100, sortable: true, editable: true }
],
data: JSON.parse(data),
rowno: 10,
loadonce: true,
multiselect: true,
rowlist: [5, 10, 20],
pager: '#pager',
viewrecords: true,
gridview: true,
sortorder: 'asc',
toppager: true,
editurl: 'MyTestPage.aspx/EditUpdateDelete',
cloneToTop: true,
async: false,
altrows: true,
autowidth: false,
hoverrows: true,
height: 200,
// rownumbers: true,
caption: "User Data"
});
$('#list').jqGrid('navGrid', '#pager',
{
edit: true,
add: true,
del: true,
search: true,
searchtext: "Search",
addtext: "Add",
edittext: "Edit",
deltext: "Delete",
cloneToTop: true
},
{
//update
recreateForm: true,
reloadAfterSubmit: false,
width: 500,
closeAfterEdit: true,
ajaxEditOptions: { contentType: "application/json" },
serializeEditData: function (postData) {
var postdata = { 'data': postData };
return JSON.stringify(postdata);
}
},
{
// add function
recreateForm: true,
beforeShowForm: function (form) {
$('#tr_UserID', form).hide();
},
width: 500,
reloadAfterSubmit: false,
closeAfterAdd: false,
ajaxEditOptions: { contentType: "application/json" },
//onclickSubmit: function (eparams) { alert('Hi');},
serializeEditData: function (postData) {
var postdata = { 'data': postData };
return JSON.stringify(postdata);
}
},
{
ajaxDelOptions: { contentType: "application/json" },
reloadAfterSubmit: false,
onclickSubmit: function (eparams) {
var retarr = {};
var sr = $("#list").getGridParam('selrow');
rowdata = $("#list").getRowData(sr);
retarr = { UserID: rowdata.UserID };
return retarr;
},
serializeDelData: function (data) {
var postData = { 'data': data };
return JSON.stringify(postData);
}
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
}
});
</script>