I am kind of stuck in this problem for hours until now.
I am trying to update the record of a row of jTable by deleting or editing it, but every time I am facing the same error ( i.e An error occured during the communication with server ).
I tried a lot to solve this but until now no succeed at all.
I am successfully able to add record ( i.e an object of class 'Professor' ). But editing is not being performed and respective object's ( i.e Professor) controller's HTTPPost enabled method is not being executed.
I attached the screenshot.
Moreover, following is jTable code in view.
<div id="ProfessorTableContainer"></div>
<script type="text/javascript">
$(document).ready(function ()
{
$('#ProfessorTableContainer').jtable({
title: 'Professor List',
paging: true,
pageSize: 10,
sorting: false,
actions:
{
listAction: '@Url.Action("GetProfessors")',
deleteAction: '@Url.Action("DeleteProfessor")',
updateAction: '@Url.Action("UpdateProfessor")',
createAction: '@Url.Action("CreateProfessor")'
},
fields: {
ProfessorId:
{
key: true,
create: false,
edit: false,
list: false
},
ProfessorName:
{
title: 'Name',
width: '23%'
}
}
});
$('#ProfessorTableContainer').jtable('load');
//Load all records when page is first shown
});
and following is the code snippet of Controller's Update Method or Delete method.
[HttpPost]
public JsonResult DeleteProfessor(int profId)
{
try
{
ProfRepository.DeleteProfessor(profId);
return Json(new { Result = "OK" });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
I would be very much obliged is somebody helps me out. I am kind of stuck in this and don't know how to solve this. I have seen all the areas, everything seems perfect and fine enough.
Regards Usman
reason 1 : crud methods parameter name must "record"
example : public static object(Product record)
reason 2 : Model class must parameterless constructor
example : public Product() {}