How can I send the igGrid datasource to the Controller action MVC 3?
is there any reason you would like to post the whole data source to the server? If you would like to only send the changed data, you can use the transaction api of the data source / grid.
Otherwise, if you would like to send the whole datasource, here is one way to do this:
var dataSource = $("#grid").data("igGrid").dataSource.data();
url: <your controller URL>,
Hope it helps. Thanks,
I tried your suggestion, but when the message gets to the server is said undefined. Do you know why the message is undefined?
var dataSource = $('#grid1').data('igGrid').dataSource.data();
I think the problem is that I need to convert the datasource (array of objects) to json array. How do I get the datasource in json format?
I was able to get the data to the server using the following line of code. The trick was to use JSON.stringfy function, which is the same function that the grid uses when calling savechanges.
"/SaveGridData/", data: JSON.stringify(dataSource), type: 'POST', contentType: "application/json, charset=utf-8", dataType: "json"
Please let me know if this sounds correct to you.
Thank you so much for your help.
yes sounds correct. Thanks