I have used the jTable plugin of jQuery in my CRUD application. My problem is, when I click on the Add New Record, a confirmation dialog appears in but after filling the details and clicking the Save button the dialog doesn't disappear, but the data is added while i refresh the Jtable..how i can close the popup window?
my View contains
$(document).ready(function () {
$('#StudentTableContainer').jtable({
title: 'Employee List',
paging: true, //Enable paging
sorting: true, //Enable sorting
defaultSorting: 'Name ASC',
//openChildAsAccordion: true, //Enable this line to show child tabes as accordion style
actions: {
listAction: '@Url.Action("Details")',
deleteAction: '@Url.Action("Delete")',
updateAction: '@Url.Action("Update")',
createAction: '@Url.Action("Create")'
},
recordAdded: function (event, data) {
$('#StudentTableContainer').jtable('reload');
},
fields: {
UserId: {
key: true,
create: false,
edit: false,
list: false
},
FirstName: {
title: 'FirstName',
width: '10%'
},
LastName: {
title: 'LastName',
width: '10%'
},
EMail: {
title:'EMail',
width: '10%'
},
Address: {
title: 'Address',
width: '10%'
},
PhoneNo: {
title:'PhoneNo',
width: '10%'
},
Company: {
title:'Company',
width:'10%'
},
Designation: {
title:'Designation',
width:'10%'
}
}
});
//Load person list from server
$('#StudentTableContainer').jtable('load');
and my controller has Create method contains
[HttpPost] public JsonResult Create(UserList userList) {
try
{
userRepository.InsertUser(userList);
return Json(new { Result = "OK" });
}
catch (Exception exception)
{
return Json(new { Result = "ERROR", Message = exception.Message });
}
}
Record must be an object, not array of objects. you must check json response from browser.
{"Result":"OK","Record":[{"id":"2","item_id":"6","marked_number":"MN567","p_model":"MDL","p_number":"PNUM","claimed_defects":"CLDEF"}]}
It must be this:
{"Result":"OK","Record":{"id":"2","item_id":"6","marked_number":"MN567","p_model":"MDL","p_number":"PNUM","claimed_defects":"CLDEF"}}
Plus another issue, I was dealing with this problem for a few days and here it is solved in ONE letter (Record vs. Records)