-<html>\r
-<head>\r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.PagingToolbar"></div>/**
+<html>
+<head>
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+<div id="cls-Ext.PagingToolbar"></div>/**
* @class Ext.PagingToolbar
* @extends Ext.Toolbar
* <p>As the amount of records increases, the time required for the browser to render
Ext.QuickTips.init(); // to display button quicktips
var myStore = new Ext.data.Store({
+ reader: new Ext.data.JsonReader({
+ {@link Ext.data.JsonReader#totalProperty totalProperty}: 'results',
+ ...
+ }),
...
});
-var myPageSize = 25; // server script should only send back 25 items
+var myPageSize = 25; // server script should only send back 25 items at a time
var grid = new Ext.grid.GridPanel({
...
* <pre><code>
store.load({
params: {
- start: 0, // specify params for the first page load if using paging
+ // specify params for the first page load if using paging
+ start: 0,
limit: myPageSize,
+ // other params
foo: 'bar'
}
});
+ * </code></pre>
+ *
+ * <p>If using {@link Ext.data.Store#autoLoad store's autoLoad} configuration:</p>
+ * <pre><code>
+var myStore = new Ext.data.Store({
+ {@link Ext.data.Store#autoLoad autoLoad}: {params:{start: 0, limit: 25}},
+ ...
+});
+ * </code></pre>
+ *
+ * <p>The packet sent back from the server would have this form:</p>
+ * <pre><code>
+{
+ "success": true,
+ "results": 2000,
+ "rows": [ // <b>*Note:</b> this must be an Array
+ { "id": 1, "name": "Bill", "occupation": "Gardener" },
+ { "id": 2, "name": "Ben", "occupation": "Horticulturalist" },
+ ...
+ { "id": 25, "name": "Sue", "occupation": "Botanist" }
+ ]
+}
* </code></pre>
* <p><u>Paging with Local Data</u></p>
* <p>Paging can also be accomplished with local data using extensions:</p>
* <div class="mdetail-params"><ul>
- * <li><a href="http://extjs.com/forum/showthread.php?t=57386">Ext.ux.data.PagingStore</a></li>
+ * <li><a href="http://extjs.com/forum/showthread.php?t=71532">Ext.ux.data.PagingStore</a></li>
* <li>Paging Memory Proxy (examples/ux/PagingMemoryProxy.js)</li>
* </ul></div>
* @constructor Create a new PagingToolbar
tooltip: this.refreshText,
overflowText: this.refreshText,
iconCls: 'x-tbar-loading',
- handler: this.refresh,
+ handler: this.doRefresh,
scope: this
})];
);
this.on('afterlayout', this.onFirstLayout, this, {single: true});
this.cursor = 0;
- this.bindStore(this.store);
+ this.bindStore(this.store, true);
},
// private
return this.paramNames || this.store.paramNames;
},
+ // private
+ getParams : function(){
+ //retain backwards compat, allow params on the toolbar itself, if they exist.
+ return this.paramNames || this.store.paramNames;
+ },
+
// private
beforeLoad : function(){
if(this.rendered && this.refresh){
this.doLoad(extra ? (total - extra) : total - this.pageSize);
},
- <div id="method-Ext.PagingToolbar-refresh"></div>/**
+ <div id="method-Ext.PagingToolbar-doRefresh"></div>/**
* Refresh the current page, has the same effect as clicking the 'refresh' button.
*/
- refresh : function(){
+ doRefresh : function(){
this.doLoad(this.cursor);
},
bindStore : function(store, initial){
var doLoad;
if(!initial && this.store){
- this.store.un('beforeload', this.beforeLoad, this);
- this.store.un('load', this.onLoad, this);
- this.store.un('exception', this.onLoadError, this);
if(store !== this.store && this.store.autoDestroy){
this.store.destroy();
+ }else{
+ this.store.un('beforeload', this.beforeLoad, this);
+ this.store.un('load', this.onLoad, this);
+ this.store.un('exception', this.onLoadError, this);
+ }
+ if(!store){
+ this.store = null;
}
}
if(store){
load: this.onLoad,
exception: this.onLoadError
});
- doLoad = store.getCount() > 0;
+ doLoad = true;
}
this.store = store;
if(doLoad){
});
})();
-Ext.reg('paging', Ext.PagingToolbar);</pre> \r
-</body>\r
+Ext.reg('paging', Ext.PagingToolbar);</pre>
+</body>
</html>
\ No newline at end of file