Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 4 Jquery DataTable Paging Loses Model Reference
    primarykey
    data
    text
    <p>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.</p> <pre><code> &lt;table id="tblAvailableFranchisees"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Franchisee&lt;/th&gt; &lt;th&gt;Email Address&lt;/th&gt; &lt;th&gt;&lt;input type="checkbox" /&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; @for (int i = 0; i &lt; Model.ListUsers.Count; i++) { &lt;tr id="@Model.ListUsers[i].UserId"&gt; @Html.HiddenFor(m =&gt; m.ListUsers[i].UserId) &lt;td&gt;@Html.DisplayFor(m =&gt; m.ListUsers[i].DisplayName)&lt;/td&gt; &lt;td&gt;@Html.DisplayFor(m =&gt; m.ListUsers[i].EmailAddress)&lt;/td&gt; &lt;td&gt;@Html.CheckBoxFor(m =&gt; m.ListUsers[i].InGroup)&lt;/td&gt; &lt;/tr&gt; } &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Now I have implemented the JQuery DataTable with it. </p> <pre><code> $(document).ready(function () { var oTable = $('#tblAvailableFranchisees').dataTable(); {); </code></pre> <p>The DataTable renders correctly, with giving me the default ability to sort columns, select pages and select the number of records per page. </p> <p>I can then check the users via the checkbox and post and the Model passed to my controller gives me what I want. </p> <p>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. </p> <p>Open to any ideas to help investigate this. thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload