Total members 11895 |It is currently Sun Dec 22, 2024 8:00 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Adding pagination to table with JQuery - show paging under table or any html content
javascript code
<html>
<head>
<title>Add paging to table</title>

<!--
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
Note you can download the JQuery package instead of using Google version. -->
<script src="jquery-1.8.3.js"></script>
<script type='text/javascript' src='jquery-latest.js'></script>
<script type='text/javascript' src='jquery.tablesorter.js'></script>
<script type='text/javascript' src='jquery.tablesorter.pager.js'></script>
<script>
$(document).ready(function() {


$("#tablePage")
.tablesorter({widthFixed: false})
.tablesorterPager({container: $("#pager")});
});

</script>


</head>
<body>
<table id="tablePage" border="1px">
<thead>
<tr>
<th>ID</th>
<th>Student Name</th>
<th>Department</th>
<th>Class</th>
<th>GPA</th>
</tr>
</thead>
<tbody>
<tr>
<td>323</td>
<td>Smith</td>
<td>Computer Science</td>
<td>C1</td>
<td>3.4</td>
</tr>
<tr>
<td>345</td>
<td>Johan</td>
<td>Computer Science</td>
<td>A1</td>
<td>2.7</td>
</tr>
<tr>
<td>21</td>
<td>Ali</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.0</td>
</tr>
<tr>
<td>33</td>
<td>Tonson</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.2</td>
</tr>
<tr>
<td>323</td>
<td>Smith</td>
<td>Computer Science</td>
<td>C1</td>
<td>3.4</td>
</tr>
<tr>
<td>345</td>
<td>Johan</td>
<td>Computer Science</td>
<td>A1</td>
<td>2.7</td>
</tr>
<tr>
<td>21</td>
<td>Ali</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.0</td>
</tr>
<tr>
<td>33</td>
<td>Tonson</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.2</td>
</tr>
<tr>
<td>323</td>
<td>Smith</td>
<td>Computer Science</td>
<td>C1</td>
<td>3.4</td>
</tr>
<tr>
<td>345</td>
<td>Johan</td>
<td>Computer Science</td>
<td>A1</td>
<td>2.7</td>
</tr>
<tr>
<td>21</td>
<td>Ali</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.0</td>
</tr>
<tr>
<td>33</td>
<td>Tonson</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.2</td>
</tr>
<tr>
<td>323</td>
<td>Smith</td>
<td>Computer Science</td>
<td>C1</td>
<td>3.4</td>
</tr>
<tr>
<td>345</td>
<td>Johan</td>
<td>Computer Science</td>
<td>A1</td>
<td>2.7</td>
</tr>
<tr>
<td>21</td>
<td>Ali</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.0</td>
</tr>
<tr>
<td>33</td>
<td>Tonson</td>
<td>Electric Engineering</td>
<td>EE4</td>
<td>3.2</td>
</tr>
</tbody>
</table>
<div id="pager" class="pager">
<form>
<table>
<tr>
<td><div class="first"/><b>First</b></div></td>
<td>|</td>
<td><div class="prev"/><b>Prev</b></div></td>
<td>|</td>
<td><input type="text" class="pagedisplay"/></td>
<td>|</td>
<td><div class="next" ><b>Next</b></div></td>
<td>|</td>
<td><div class="last" ><b>Last</b></div></td>
<td>|</td>
<td>Number Of Rows:<select class="pagesize">
<option selected="selected" value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select></td>
</tr>
</table>
</form>
</div>

</body>

</html>


To run this code you will need jquery.tablesorter.pager.js:
javascript code
<script type='text/javascript' src='jquery.tablesorter.pager.js'></script>

Download it from here :
Attachment:
jquery.tablesorter.pager.js [3.98 KiB]
Downloaded 3920 times


Or you can get them from original web page :
Code:
http://tablesorter.com

Topic below contains information about
jquery-examples/sort-html-table-from-jquery-t10729.html



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : add pagination to html page using JQuery
 Sort HTML table from JQuery     -  
 Get the position of HTML element using JQuery     -  
 get HTML elements attributes values using JQuery     -  
 checking if a HTML element is visible or hidden under JQuery     -  
 Show hint when focus on html element using JQuery     -  
 keywords and description of HTML page using meta tag     -  
 draw a horizontal line in your html page     -  
 add pagination using PHP     -  
 Image Scroller-scrollbar-LINE_UP,LINE_DOWN-PAGE-UP-PAGE-DOWN     -  
 JQuery Animations     -  



Topic Tags

JQuery Table






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com