jQuery DataTables 将数据发布到服务器
我有一个 ASP.NET MVC 3 应用程序,并且使用 jQuery DataTables 作为网格。 我需要在客户端管理网格数据,然后将其发布到服务器并进行处理。 做到这一点最简单的方法是什么?如何将 DataTables 中的 json 与其他表单数据一起发布?有没有办法将 JSON 从 DataTables 映射到 C# 对象? 谢谢你!
I have an ASP.NET MVC 3 app and I'm using jQuery DataTables as grid.
I need to manage grids' data on client side and then post it to the server and process it then.
What's the easiest way of doing this? How to post json from DataTables along with other form data? And is there any way to map JSON from DataTables to C# objects?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是有关如何将 jQuery 数据表与 MVC 集成的指南:
http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part
Here is a guide on how to integrate jQuery datatables with MVC:
http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part
对于笼统的回应感到抱歉...在这种情况下,代码示例和研究可能最好推迟:
我个人很想使用 DataTables 的
fnGetData
函数将表作为数组获取。此时,您可以使用适当的工具将其转换为您需要的任何格式,并将其发布到服务器端。至少有一个众所周知的 JSON 实用程序(json.js 我认为它被称为...?)可以转换为 JSON,此时您可能需要对其进行字符串化。然后您将发布它,然后如果 ASP.NET 已有实用程序,则转换为 C## 对象。
直到最后我才想问这个:为什么需要 POST 整个表?您可能最好只发布包含您已更新的值的单元格等。
Sorry for the generalized response... code samples and research are probably best deferred in this case:
I would personally be tempted to use DataTables'
fnGetData
function to grab the table as an array. At that point you can use an appropriate tool to convert it to whatever format you need, and post it to your server-side.There is at least one well known JSON utility (json.js I think it's called...?) that can convert to JSON, at which point you would probably need to stringify it. Then you would post it, and then if ASP.NET already has a utility, convert over to a C## object.
Only at the end do I think to ask this: why is there a need to POST the whole table? You might be better off only POSTing cells with values that you've updated, etc.
我已经制作了 DataTables 的替代方案,可以轻松发布附加数据,因为我的插件在获取数据时使用表单。
https://github.com/jgauffin/Griffin.Table/wiki/Basic-usage
它还获得了 MVC3 集成包:
https://github.com/jgauffin/Griffin.Table/wiki/Asp.net-mvc3-introduction
I've made an alternative to DataTables where it's easy to post additional data since my plugin uses a form while fetching data.
https://github.com/jgauffin/Griffin.Table/wiki/Basic-usage
It also got an MVC3 integration package:
https://github.com/jgauffin/Griffin.Table/wiki/Asp.net-mvc3-introduction