Ismail Vittal Ismail Vittal - 1 month ago 19
Javascript Question

Javascript Array Table Pagination

I want to achieve pagination (5 records per page) for this simple JavaScript array table having pagination controls.

So far I created a table with data:

jsfiddle.net/QwBsa/13/


Can anyone route me to any demo or reference ?

Answer

try to use jQuery.dataTables...which gives the pagination as well as sorting options include this

   <link href="css/demo_page.css" rel="stylesheet" id="stylesheet"/>
      <link href="css/demo_table.css" rel="stylesheet" />
     <script  src="js/jquery.dataTables.js"></script>

and create table as like yours in javascript and declare class name as "abc"

               var table = document.createElement('table');
               table.setAttribute("class","abc");
              var tbody = document.createElement('tbody');

and call jquery display length will be the number of data to be displayed,

jQuery call:

        $('#abc').dataTable({

        "iDisplayLength": 5,

           });

for reference use see website

www.datatables.net

Comments