philzhou

导航

easyui 1.2.4 +aspnet mvc常见问题

1. form提交回调函数无法触发,服务器端返回json被浏览器获取。

function saveUser() {
$(
'#fm').form('submit', {
url: url,
onSubmit:
function () {
return $(this).form('validate');
},
success:
function (result) {
var result = eval('(' + result + ')');
if (result.success) {
$(
'#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
} else {
$.messager.show({
title:
'Error',
msg: result.msg
});
}
}
});
}

服务器端代码

public JsonResult AddCustomer(Customer cust)
{
string result = "";
try
{
TestEntities data
= new TestEntities();
data.AddToCustomers(cust);
data.SaveChanges();
result
= "成功";
}
catch (Exception ex)
{
result
= ex.Message;
}

return this.Json(new { success = true }, JsonRequestBehavior.AllowGet);
}

该Action返回的Json直接被浏览器截获了,而没有触发前端ajax的回调函数。

解决办法:

return this.Json(new { success = true },"text/html", JsonRequestBehavior.AllowGet);

 2.  easyui 1.2.4 bug 在一个允许多选的datagrid中删除了选中的某一行记录,并reload datagrid数据之后, 发现该已删除的记录任然存在于getSelections返回的row中,并且是第一行即如果getSelected会发现返回的时已被删除的那条记录。

解决方法:

重新加载数据前先清除 Selections

$('#test').datagrid("clearSelections");

 

 

posted on 2011-08-27 15:26  philzhou  阅读(572)  评论(0编辑  收藏  举报