| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | "http://www.w3.org/TR/html4/loose.dtd"> |
| 3 | <html dir="ltr"> |
| 4 | <head> |
| 5 | <title>Test Pagination plugin of dojox.grid.EnhancedGrid</title> |
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 7 | <link rel=stylesheet href="support/common.css"/> |
| 8 | <style type="text/css"> |
| 9 | body { |
| 10 | font-size: 0.9em; |
| 11 | font-family: Geneva, Arial, Helvetica, sans-serif; |
| 12 | padding-right: 10em; |
| 13 | } |
| 14 | .title { |
| 15 | text-align:center; |
| 16 | margin:1em; |
| 17 | } |
| 18 | #grid{ |
| 19 | width: 100em; |
| 20 | height: 30em; |
| 21 | } |
| 22 | #API-btn-grp{ |
| 23 | margin: 1em; |
| 24 | } |
| 25 | </style> |
| 26 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug:false, parseOnLoad: true"></script> |
| 27 | <script type="text/javascript" src="../../../../dijit/tests/_testCommon.js"></script> |
| 28 | <script type="text/javascript"> |
| 29 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 30 | dojo.require("dojox.grid.EnhancedGrid"); |
| 31 | dojo.require("dojox.grid.enhanced.plugins.Pagination"); |
| 32 | dojo.require("dojo.parser"); |
| 33 | dojo.require('dijit.form.NumberTextBox'); |
| 34 | dojo.require('dijit.form.Button'); |
| 35 | dojo.require('dijit.form.Select'); |
| 36 | |
| 37 | var layout = [{ |
| 38 | cells: [ |
| 39 | { field: "id", name:"Identity", datatype:"number", width: 4}, |
| 40 | { field: "Genre", name:"Genre", datatype:"string", width: 10}, |
| 41 | { field: "Artist", name:"Artist", datatype:"string", width: 10}, |
| 42 | { field: "Year", name:"Year", datatype:"string", width: 2.5}, |
| 43 | { field: "Album", name:"Album", datatype:"string", width: 10}, |
| 44 | { field: "Name", name:"Name", datatype:"string", width: 8}, |
| 45 | { field: "Length", name:"Length", datatype:"string", width: 4}, |
| 46 | { field: "Track", name:"Track", datatype:"number", width: 3}, |
| 47 | { field: "Composer", name:"Composer", datatype:"string", width: 12}, |
| 48 | { field: "Download Date", name:"Download Date", datatype:"date", width: 12}, |
| 49 | { field: "Last Played", name:"Last Played", datatype:"time", width: 6}, |
| 50 | { field: "Heard", name: "Checked", datatype:"boolean", width: 6} |
| 51 | ] |
| 52 | }]; |
| 53 | var plugins = { |
| 54 | pagination: { |
| 55 | pageSizes: [10, 25, 30, 50, 100, Infinity],// Array, custom the items per page button |
| 56 | description: true, // boolean, custom whether or not the description will be displayed |
| 57 | sizeSwitch: true, // boolean, custom whether or not the page size switch will be displayed |
| 58 | pageStepper: true, // boolean, custom whether or not the page step will be displayed |
| 59 | gotoButton: true, // boolean, custom whether or not the goto page button will be displayed |
| 60 | maxPageStep: 10, // Integer, custom how many page step will be displayed |
| 61 | position: "bottom", // String, custom the position of the pagination bar. There're two options: top, bottom |
| 62 | defaultPage: 2, // Integer, which page will be displayed by default |
| 63 | defaultPageSize: 25 // Integer, what page size will be used by default |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | var grid; |
| 68 | dojo.ready(function(){ |
| 69 | grid = dijit.byId("grid"); |
| 70 | }); |
| 71 | |
| 72 | function currentPageSize(){ |
| 73 | grid.currentPageSize(dijit.byId("pagesize").value); |
| 74 | } |
| 75 | |
| 76 | function currentPage(){ |
| 77 | grid.currentPage(dijit.byId("page").value); |
| 78 | } |
| 79 | |
| 80 | function scrollToRow(){ |
| 81 | grid.scrollToRow(dijit.byId("row").value - 1); |
| 82 | } |
| 83 | </script> |
| 84 | <script type="text/javascript" src="support/test_write_store_music.js"></script> |
| 85 | </head> |
| 86 | <body class="claro"> |
| 87 | <h1 class="title">dojox.grid.EnhancedGrid - Pagination</h1> |
| 88 | <div id='API-btn-grp'> |
| 89 | <input data-dojo-type="dijit.form.NumberTextBox" id="pagesize" data-dojo-id="pagesize" data-dojo-props="style:{width:'40px'}"></input> |
| 90 | <button data-dojo-type="dijit.form.Button" onclick="currentPageSize()">Set Page Size</button> |
| 91 | | |
| 92 | <button data-dojo-type="dijit.form.Button" onclick="grid.firstPage()">first page</button> |
| 93 | <button data-dojo-type="dijit.form.Button" onclick="grid.prevPage()">previous page</button> |
| 94 | | |
| 95 | Page: |
| 96 | <input data-dojo-type="dijit.form.NumberTextBox" id="page" data-dojo-id="page" data-dojo-props="style:{width:'40px'}"></input> |
| 97 | <button data-dojo-type="dijit.form.Button" onclick="currentPage()">Go</button> |
| 98 | | |
| 99 | <button data-dojo-type="dijit.form.Button" onclick="grid.nextPage()">next page</button> |
| 100 | <button data-dojo-type="dijit.form.Button" onclick="grid.lastPage()">last page</button> |
| 101 | | |
| 102 | Goto specific row: |
| 103 | <input data-dojo-type="dijit.form.NumberTextBox" id="row" data-dojo-id="row" data-dojo-props="style:{width:'40px'}"></input> |
| 104 | <button data-dojo-type="dijit.form.Button" onclick="scrollToRow()">Go</button> |
| 105 | </div> |
| 106 | <div id="gridContainer"> |
| 107 | <div id="grid" dojoType="dojox.grid.EnhancedGrid" store="test_store[0]" structure="layout" plugins="plugins" summary="A customized grid summary"></div> |
| 108 | </div><br/> |
| 109 | <p><strong>Note:</strong> To see the tundra theme, just append <b style="color:blue;">?theme=tundra</b> to the URL.</p> |
| 110 | </body> |
| 111 | </html> |