Sedikit Info Seputar
How to add jQuery pagination to any table in minute?
Terbaru 2017
- Hay gaes kali ini team Official Sahabat Android, kali ini akan membahas artikel dengan judul How to add jQuery pagination to any table in minute?, kami selaku Team Official Sahabat Android telah mempersiapkan artikel ini untuk sobat sobat yang menyukai Official Sahabat Android. semoga isi postingan tentang
Artikel HTML5,
Artikel javascript,
Artikel Jquery,
Artikel programming,
Artikel table, yang saya posting kali ini dapat dipahami dengan mudah serta memberi manfa'at bagi kalian semua, walaupun tidak sempurna setidaknya artikel kami memberi sedikit informasi kepada kalian semua. ok langsung simak aja sob
Judul:
Berbagi Info Seputar
How to add jQuery pagination to any table in minute?
Terbaru
link: How to add jQuery pagination to any table in minute?
Berbagi How to add jQuery pagination to any table in minute? Terbaru dan Terlengkap 2017
What’s my idea?
Initiating pagination in table
Adding Google ajax api in your html head section
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> </head> |
Adding pagination class to your table
<table class=”paginated-table”> . . . |
Adding navigation below table
<span class="prev btn btn-rounded btn-light"><i class="fa fa-angle-double-left"></i> Previous</span> <span class="next btn btn-rounded btn-light"><i class="fa fa-angle-double-right"></i> Next</span> |
Adding pagination script
<script> var maxRows = 5; // Define per page element count $('.paginated-table').each(function() { var cTable = $(this); var cRows = cTable.find('tr:gt(0)'); var cRowCount = cRows.size(); if (cRowCount < maxRows) { return; } cRows.each(function(i) { $(this).find('td:first').text(function(j, val) { return (i + 1) + " - " + val; }); }); cRows.filter(':gt(' + (maxRows - 1) + ')').hide(); var cPrev = cTable.siblings('.prev'); var cNext = cTable.siblings('.next'); cPrev.addClass('disabled'); cPrev.click(function() { var cFirstVisible = cRows.index(cRows.filter(':visible')); if (cPrev.hasClass('disabled')) { return false; } cRows.hide(); if (cFirstVisible - maxRows - 1 > 0) { cRows.filter(':lt(' + cFirstVisible + '):gt(' + (cFirstVisible - maxRows - 1) + ')').show(); } else { cRows.filter(':lt(' + cFirstVisible + ')').show(); } if (cFirstVisible - maxRows <= 0) { cPrev.addClass('disabled'); } cNext.removeClass('disabled'); return false; }); cNext.click(function() { var cFirstVisible = cRows.index(cRows.filter(':visible')); if (cNext.hasClass('disabled')) { return false; } cRows.hide(); cRows.filter(':lt(' + (cFirstVisible +2 * maxRows) + '):gt(' + (cFirstVisible + maxRows - 1) + ')').show(); if (cFirstVisible + 2 * maxRows >= cRows.size()) { cNext.addClass('disabled'); } cPrev.removeClass('disabled'); return false; }); }); </script> |