JTable的:在更新或删除记录“,同时与服务器通信时出错” [英] JTable : 'An error occured while communicating with the server ' while updating or deleting records
问题描述
我种卡在这个问题了几个小时,直到如今。
我试图删除或编辑它来更新JTable中的行的记录,但每次我面临着同样的错误(即与服务器通信时发生错误)。
我尝试了很多解决这一点,但到现在为止没有成功可言。
我能够成功添加记录(即类教授的对象)。但编辑不被执行,并且没有被执行各自的对象的(即教授)控制器的HTTPPost启用方法。
我附上的截图。
此外,以下是JTable中code在视图中。
< DIV ID =ProfessorTableContainer>< / DIV>
<脚本类型=文/ JavaScript的>
$(文件)。就绪(函数()
{
$('#ProfessorTableContainer')。JTable中({
标题:名单教授,
分页:真实,
每页:10,
分类:假的,
动作:
{
的listAction:@ Url.Action(GetProfessors)',
deleteAction:@ Url.Action(DeleteProfessor)',
updateAction:@ Url.Action(UpdateProfessor)',
createAction:@ Url.Action(CreateProfessor)'
},
字段:{
ProfessorId:
{
键:真实,
创建:假的,
编辑:假的,
清单:假的
},
ProfessorName:
{
标题:名称,
宽度:'23%'
} } });
$('#ProfessorTableContainer')JTable中('负荷')。
//加载所有记录时,首先显示页 });
和下面是控制器的更新方法的code段或删除方法。
[HttpPost]
公共JsonResult DeleteProfessor(INT PROFID)
{
尝试
{
ProfRepository.DeleteProfessor(PROFID);
返回JSON(新{结果=OK});
}
赶上(异常前)
{
返回JSON(新{结果=ERROR,消息= ex.Message});
}
}
我将非常感谢是有人可以帮助我。
我有点停留在这一点,不知道如何解决此问题。我见过的所有领域,一切似乎完美,不够精细。</ P>
问候
乌斯曼
原因1 :CRUD方法的参数名称必须记录结果
例如:公共静态对象(产品记录)
原因2 :Model类必须参数的构造函数结果
例如:公共产品(){}
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() {}
这篇关于JTable的:在更新或删除记录“,同时与服务器通信时出错”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!