I am trying to use simplePagination on my code. (I am developing using MVC4 C#)
Let say I have this bunch of codes
<table>
<thead>
<tr>
<td><input type="checkbox" name="select-all" id="select-all" /></td>
<td style="text-align: left">Name</td>
<td style="text-align: left">Created By</td>
<td style="text-align: left">Created Date</td>
</tr>
</thead>
<tbody>
<tr class="post">
<td><p><input Length="0" name="314" type="checkbox" value="true" /><input name="314" type="hidden" value="false" /></p></td>
<td>Window</td>
<td>John</td>
<td>01/01/2014 12:00:00 AM</td>
</tr>
<tr class="post">
<td><p><input Length="0" name="314" type="checkbox" value="true" /><input name="314" type="hidden" value="false" /></p></td>
<td>Door</td>
<td>Chris</td>
<td>01/01/2014 12:00:00 AM</td>
</tr>
<tr class="post">
<td><p><input Length="0" name="314" type="checkbox" value="true" /><input name="314" type="hidden" value="false" /></p></td>
<td>Floor</td>
<td>Michael</td>
<td>01/01/2014 12:00:00 AM</td>
</tr>
<tr class="post">
<td><p><input Length="0" name="314" type="checkbox" value="true" /><input name="314" type="hidden" value="false" /></p></td>
<td>Car</td>
<td>James</td>
<td>01/01/2014 12:00:00 AM</td>
</tr>
<tr class="post">
<td><p><input Length="0" name="314" type="checkbox" value="true" /><input name="314" type="hidden" value="false" /></p></td>
<td>Bike</td>
<td>Steven</td>
<td>01/01/2014 12:00:00 AM</td>
</tr>
</tbody>
</table>
*Note: In the code above I add class 'post' to each 'tr' (row in table body). And these rows are generated dynamically by for loop (C#)
And from the documentation if I want to use simplePagination I have to declare the jquery like this:
$(function() {
$(selector).pagination({
items: 100,
itemsOnPage: 10,
cssStyle: 'light-theme'
});
});
Actually I am not pretty sure how to use (*how to call) this simplePagination. It's my first time dealing with pagination.
I already tried to put this code after the table
<div class="pagination-page"></div>
And change 'Selector' inside jquery calling method with '.pagination-page', but it didn't work.
$(function() {
$('.pagination-page').pagination({
items: 100,
itemsOnPage: 10,
cssStyle: 'light-theme'
});
});
- Should I replace 'Selector' with a class name? If yes, how do I do that?
- Second is how do I declare this simplePagination so that it will show only 2 rows (Only 2 class 'Post') for each page?
*Means in the first page it will only show
+--------------------------------------------------+
| [] | Name | CreatedBy | CreatedDate |
|--------------------------------------------------|
| [] | Window | John | 01/01/2014 12:00:00 AM |
| [] | Door | Chris | 01/01/2014 12:00:00 AM |
+--------------------------------------------------+
The second page will show
+--------------------------------------------------+
| [] | Name | CreatedBy | CreatedDate |
|--------------------------------------------------|
| [] | Floor | Michael | 01/01/2014 12:00:00 AM |
| [] | Car | James | 01/01/2014 12:00:00 AM |
+--------------------------------------------------+
So on..
*Note: I am not sure how this jquery will detect how many items we have and generate number of pages and put those items accordingly.
See Question&Answers more detail:
os