This is the view I have for my table. When I post back to my controller, my model will give me the items in ListUsers and set the properties of "InGroup" = true (if checked), and the UserId that it was checked for. This works completely fine.
<table id="tblAvailableFranchisees">
<thead>
<tr>
<th>Franchisee</th>
<th>Email Address</th>
<th><input type="checkbox" /></th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.ListUsers.Count; i++)
{
<tr id="@Model.ListUsers[i].UserId">
@Html.HiddenFor(m => m.ListUsers[i].UserId)
<td>@Html.DisplayFor(m => m.ListUsers[i].DisplayName)</td>
<td>@Html.DisplayFor(m => m.ListUsers[i].EmailAddress)</td>
<td>@Html.CheckBoxFor(m => m.ListUsers[i].InGroup)</td>
</tr>
}
</tbody>
</table>
Now I have implemented the JQuery DataTable with it.
$(document).ready(function () {
var oTable = $('#tblAvailableFranchisees').dataTable();
{);
The DataTable renders correctly, with giving me the default ability to sort columns, select pages and select the number of records per page.
I can then check the users via the checkbox and post and the Model passed to my controller gives me what I want.
However when I go onto a different page in the table, and post, the Model passed to my controller is now a null collection. I've confirmed that it is related to the paging, but cannot seem to figure out why the Model would return a null collection and not return the items in the table.
Open to any ideas to help investigate this. thanks in advance