Click here to Skip to main content
14,919,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am very new to asp.net and jquery. I need to implement paging to my gridview control using jquery. I googled and found the solution. but i don't the jquery logic. can any one explain me the following script.
paging in gridview in asp.net using jquery

JavaScript
$(document).ready(function () {
            $('#GridView1').after('<div id="nav"></div>');
            var rowsShown = 5;
            var rowsTotal = $('#GridView1 tbody tr').not(':first').length;
            var numPages = rowsTotal / rowsShown;
            for (i = 0; i < numPages; i++) {
                var pageNum = i + 1;
                $('#nav').append('<a href="#" rel="' + i + '">' + pageNum + '</a> ');
            }
            $('#GridView1 tbody tr').not(':first').hide();
            $('#GridView1 tbody tr').not(':first').slice(0, rowsShown).show();
            $('#nav a:first').addClass('active');
            $('#nav a').bind('click', function () {
 
                $('#nav a').removeClass('active');
                $(this).addClass('active');
                var currPage = $(this).attr('rel');
                var startItem = currPage * rowsShown;
                var endItem = startItem + rowsShown;
                $('#GridView1 tbody tr').not(':first').css('opacity', '0.0').hide().slice(startItem, endItem).
                        css('display', 'table-row').animate({ opacity: 1 }, 300);
            });
        });
Posted
Comments
   
Where exactly you don't understand?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900