JQGrid 传递Json参数至控制器
来源:互联网 发布:ubuntu设置镜像源 编辑:程序博客网 时间:2024/06/06 08:32
serializeEditData后 Controller中就取不到参数了,一直为null
后来采用扩展ModelBinder方法
很奇怪也绑定失败,后来发现controllerContext.HttpContext.Request.Form[bindingContext.ModelName] 为空。赶进度,没办法只能用controllerContext.HttpContext.Request.Form[0],以后再研究吧
网页
var editSettings = {
closeAfterEdit: true,
reloadAfterSubmit: true,
closeOnEscape: true,
datatype: 'json',
serializeEditData: function(postdata) {
return JSON.stringify(postdata);
}
};
var addSettings = {
closeAfterAdd: true,
reloadAfterSubmit: true,
closeOnEscape: true,
datatype: 'json',
serializeEditData: function(postdata) {
return JSON.stringify(postdata);
}
};
var delSettings = {
reloadAfterSubmit: true,
closeOnEscape: true,
datatype: 'json',
serializeDelData: function(postdata) {
return JSON.stringify(postdata);
}
};
$("#gridTable").jqGrid('navGrid', '#gridPager',
{ add: true, edit: true, del: true, search: false },
editSettings, // edit options
addSettings, // add options
delSettings, // del options
{}// {closeOnEscape:true}, // search options
// {height:250,jqModal:false,closeOnEscape:true} // view options
);
public class JQGridParameterBind<T> : IModelBinder
{
#region IModelBinder 成员
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var json = controllerContext.HttpContext.Request.Form[0] as string;
var jss = new JavaScriptSerializer();
return jss.Deserialize<Dictionary<string, object>>(json);
}
}
Controller
[HttpPost()]
public ActionResult Save([ModelBinder(typeof(JQGridParameterBind<Dictionary<string, object>>))] Dictionary<string, object> postdata)
{
......
}
- JQGrid 传递Json参数至控制器
- jqgrid--动态传递json数据
- Struts2与jqGrid的参数传递
- WebApi传递JSON参数
- Http传递json参数
- WebApi传递JSON参数
- IOS视图控制器间参数传递
- ajax向控制器传递多个参数
- jqgrid json
- jqGrid学习--- jqGrid参数
- AJAJX 使用JSON传递参数
- jqGrid参数
- jqgrid参数
- jqGrid参数
- WebApi传递JSON参数 接收不到参数
- JqGrid往后台传递查询参数使用Filters时的参数类型转换.
- springMVC视图层和控制器层之间参数传递
- thinkphp框架中ajax向控制器传递参数数组
- 时代周刊2011年度50大最佳发明揭晓
- Web开发中常见的java.lang.IllegalStateException错误
- C#数组研究
- .NET简谈事务本质论
- ExtJs之Ext.data.Store
- JQGrid 传递Json参数至控制器
- Windows7(旗舰版)下安装SQL Server 2005注意事项及问题解决
- qt4 sqlite fedora
- 当我们遭遇2038年1月19日该怎么办?
- mysql的安装与注意事项
- Android 调试桥
- qt4 sqlite micro2440
- Qt创建和使用动态链接库
- Sipdroid数据发送流程