I'm using MVC3 to create a web application. In my web application I have a datatable displaying object values with a checkbox on each row that the user can check/uncheck. What I would like to do is to fix a setup so that the user can check/uncheck as many boxes as he/she wants without anything happening. Then when de user is done he/she presses a "done" button next to the table. Now this is when I want the magic to happen. I would like the view to collect all rows into an array so I can send the whole table to a controller method. I found in the datatables api that i can use the code
var table = $.fn.dataTable.fnTables(true);
if (table.length > 0) {
$(table).dataTable().fnAdjustColumnSizing();
}
in order to save all the datatable data into a variable. Now how do I use this?
In addition to that I want all of this to happen when the user presses my Ajax.ActionLink that is currently today only returning another view. Would it be possible to also have my ActionLink set a variable to the return value of the javascript function that returns the array of the datatable rows?
I will try to display what I'm trying to say if I'm a bit unclear (I'm currently not the best web developer so please be gentle with me :)) Please see comment in code.
@Ajax.ActionLink("Done",
"_DoneView",
new { value1 = Model.Item1.value1, value2 =
Model.Item1.value2, value3 = Model.Item1.value3,
//Would it be possible to here say something like
DatatableArray = javascriptFunction() //Javascript function
//that returns an array containing all rows from the table },
new AjaxOptions { HttpMethod = "GET",
UpdateTargetId = "DataTable",
InsertionMode = InsertionMode.Replace},
new {
@class = "linkButton blue"
Thanks for all the help and don't hesitate to ask for more info if there is something missing/is unlear.