심재운 블로그

728x90
반응형

smartpaginator.zip

 



 

Smart Paginator is a comprehensive jQuery Pagination plugin that makes adding pagination very simple task, all the navigation logic is built in and it is also very customizable. Smart Paginator jQuery Pagination plugin can also filter your data automatically on client side. Click the screen shot below for the demonstration to see the various filter options provided by Smart Paginator. Smart Paginator supports variety of parameters and custom themes, that can be used to customize the look and feel to your desire.

Smart Paginator plugin screen

Smart Paginator Parameters
  • totalrecords: Total no of records e.g. 50
  • recordsperpage: No of records on each page e.g. 10
  • controlsalways: If true next,prev,first and last buttons will be always visible
  • datacontainer: ID of HTML element which has the data you want to filter e.g id of some table
  • dataelement: Child elements type that you want to filter e.g. ‘tr’ in case your data container is a table, see the demonstration for different options.
  • length: This parameter determines the no of navigation buttons to be generated also next, prev, first and last button are displayed depending on this parameter. If value of length is greater than totalrecords/recordsperpage then next, prev, first and last buttons will not be displayed, default value of length is 10.
  • initval: Initial page to be selected, default is 0.
  • next: Text on Next button e.g. ‘Next’
  • prev: Text on Previous button e.g. ‘Prev’
  • first: Text on First button e.g. ‘First’
  • last: Text on Last button e.g. ‘Last’
  • go: Text on Go button e.g. ‘Go’
  • theme: CSS class for theme e.g.’green’
  • display: Navigation display depending on the value ‘double’ or ‘single’
  • onchange: callback function to be called on each value change, this function will give you the page no, starting index of data and end index of data.
Styling Smart Paginator

Styling Smart Paginator is very easy, you just need to define four CSS classes, for example to create theme named “green” we’ll define our CSS like below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
.green
{
    background-color: #4f7305;
}
.green.normal
{
    background-color: #588500;
    color: White;
    border: solid 1px #5f9000;
}
.green.active
{
    background-color: #344C00;
    color: #F8EB00;
    border: solid 1px #5f9000;
}
.green .btn
{
    background-color: #588500;
    color: White;
    border: solid 1px #5f9000;
}

Now you can pass “green” as a parameter value for theme in the initializer method for Smart Paginator.

Using Smart Paginator

In your HTML file add the following in the head section.

  • Add a reference to latest jQuery script
  • Add a reference to smartpaginator.js file
  • Add a reference to smartpaginator.css

Create a text block element (e.g. div)within the body of your HTML file as shown below.

1
<div id="smart-paginator" > </>

Also add the following code to your HTML file’s head section.

1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">
     $(document).ready(function() {
           $('#smart-paginator').smartpaginator({ totalrecords: 100, recordsperpage: 10, initval:0 , next: 'Next', prev: 'Prev', first: 'First', last: 'Last', theme: 'green', onchange: onChange
 
         });
 
         function onChange(newPageValue) {
             alert(newPageValue);
         }
 </script>

Here is the complete code for the example above.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <title>Smart Pagination</title>
     
    <script src="jquery-1.4.4.min.js" type="text/javascript"></script>
 
    <script src="smartpaginator.js" type="text/javascript"></script>
 
    <link href="smartpaginator.css" rel="stylesheet" type="text/css" />
 
    <script type="text/javascript">
        $(document).ready(function() {
 
            $('#smart-paginator').smartpaginator({ totalrecords: 100, recordsperpage: 10, initval:0 , next: 'Next', prev: 'Prev', first: 'First', last: 'Last', theme: 'green', onchange: onChange
 
            });
 
            function onChange(newPageValue) {
                alert(newPageValue);
            }
        });
    </script>
 
</head>
<body>
    <div id="smart-paginator">
    </div>
</body>
</html>
Update History
  • Mar 15, 2011 Published.
  • Apr 03, 2011 Updated demo and added New Parameters ‘recordStartIndex’, and ‘recordEndIndex’ to onchange callback function.
  • Apr 21, 2011 Minor issue fixed and demo updated.
  • Feb 21, 2012 Vertical alignment issue fixed.
  • Feb 22, 2012 Next,prev,first and last button visibility parameter added.

 

728x90
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band

본문과 관련 있는 내용으로 댓글을 남겨주시면 감사하겠습니다.

비밀글모드

loading