drunkcamel
drunkcamel

Reputation: 915

jQuery DataTables post data to server

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!

Upvotes: 2

Views: 6807

Answers (3)

jgauffin
jgauffin

Reputation: 101176

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

Upvotes: 0

Greg Pettit
Greg Pettit

Reputation: 10830

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.

Upvotes: 1

Rory McCrossan
Rory McCrossan

Reputation: 337700

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

Upvotes: 1

Related Questions