You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

550 lines
21 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-PagingToolbar-method-constructor'><span id='Ext-PagingToolbar'>/**
  19. </span></span> * @class Ext.PagingToolbar
  20. * @extends Ext.Toolbar
  21. * &lt;p&gt;As the amount of records increases, the time required for the browser to render
  22. * them increases. Paging is used to reduce the amount of data exchanged with the client.
  23. * Note: if there are more records/rows than can be viewed in the available screen area, vertical
  24. * scrollbars will be added.&lt;/p&gt;
  25. * &lt;p&gt;Paging is typically handled on the server side (see exception below). The client sends
  26. * parameters to the server side, which the server needs to interpret and then respond with the
  27. * approprate data.&lt;/p&gt;
  28. * &lt;p&gt;&lt;b&gt;Ext.PagingToolbar&lt;/b&gt; is a specialized toolbar that is bound to a {@link Ext.data.Store}
  29. * and provides automatic paging control. This Component {@link Ext.data.Store#load load}s blocks
  30. * of data into the &lt;tt&gt;{@link #store}&lt;/tt&gt; by passing {@link Ext.data.Store#paramNames paramNames} used for
  31. * paging criteria.&lt;/p&gt;
  32. * &lt;p&gt;PagingToolbar is typically used as one of the Grid's toolbars:&lt;/p&gt;
  33. * &lt;pre&gt;&lt;code&gt;
  34. Ext.QuickTips.init(); // to display button quicktips
  35. var myStore = new Ext.data.Store({
  36. reader: new Ext.data.JsonReader({
  37. {@link Ext.data.JsonReader#totalProperty totalProperty}: 'results',
  38. ...
  39. }),
  40. ...
  41. });
  42. var myPageSize = 25; // server script should only send back 25 items at a time
  43. var grid = new Ext.grid.GridPanel({
  44. ...
  45. store: myStore,
  46. bbar: new Ext.PagingToolbar({
  47. {@link #store}: myStore, // grid and PagingToolbar using same store
  48. {@link #displayInfo}: true,
  49. {@link #pageSize}: myPageSize,
  50. {@link #prependButtons}: true,
  51. items: [
  52. 'text 1'
  53. ]
  54. })
  55. });
  56. * &lt;/code&gt;&lt;/pre&gt;
  57. *
  58. * &lt;p&gt;To use paging, pass the paging requirements to the server when the store is first loaded.&lt;/p&gt;
  59. * &lt;pre&gt;&lt;code&gt;
  60. store.load({
  61. params: {
  62. // specify params for the first page load if using paging
  63. start: 0,
  64. limit: myPageSize,
  65. // other params
  66. foo: 'bar'
  67. }
  68. });
  69. * &lt;/code&gt;&lt;/pre&gt;
  70. *
  71. * &lt;p&gt;If using {@link Ext.data.Store#autoLoad store's autoLoad} configuration:&lt;/p&gt;
  72. * &lt;pre&gt;&lt;code&gt;
  73. var myStore = new Ext.data.Store({
  74. {@link Ext.data.Store#autoLoad autoLoad}: {params:{start: 0, limit: 25}},
  75. ...
  76. });
  77. * &lt;/code&gt;&lt;/pre&gt;
  78. *
  79. * &lt;p&gt;The packet sent back from the server would have this form:&lt;/p&gt;
  80. * &lt;pre&gt;&lt;code&gt;
  81. {
  82. &quot;success&quot;: true,
  83. &quot;results&quot;: 2000,
  84. &quot;rows&quot;: [ // &lt;b&gt;*Note:&lt;/b&gt; this must be an Array
  85. { &quot;id&quot;: 1, &quot;name&quot;: &quot;Bill&quot;, &quot;occupation&quot;: &quot;Gardener&quot; },
  86. { &quot;id&quot;: 2, &quot;name&quot;: &quot;Ben&quot;, &quot;occupation&quot;: &quot;Horticulturalist&quot; },
  87. ...
  88. { &quot;id&quot;: 25, &quot;name&quot;: &quot;Sue&quot;, &quot;occupation&quot;: &quot;Botanist&quot; }
  89. ]
  90. }
  91. * &lt;/code&gt;&lt;/pre&gt;
  92. * &lt;p&gt;&lt;u&gt;Paging with Local Data&lt;/u&gt;&lt;/p&gt;
  93. * &lt;p&gt;Paging can also be accomplished with local data using extensions:&lt;/p&gt;
  94. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  95. * &lt;li&gt;&lt;a href=&quot;http://extjs.com/forum/showthread.php?t=71532&quot;&gt;Ext.ux.data.PagingStore&lt;/a&gt;&lt;/li&gt;
  96. * &lt;li&gt;Paging Memory Proxy (examples/ux/PagingMemoryProxy.js)&lt;/li&gt;
  97. * &lt;/ul&gt;&lt;/div&gt;
  98. * @constructor Create a new PagingToolbar
  99. * @param {Object} config The config object
  100. * @xtype paging
  101. */
  102. (function() {
  103. var T = Ext.Toolbar;
  104. Ext.PagingToolbar = Ext.extend(Ext.Toolbar, {
  105. <span id='Ext-PagingToolbar-cfg-store'> /**
  106. </span> * @cfg {Ext.data.Store} store
  107. * The {@link Ext.data.Store} the paging toolbar should use as its data source (required).
  108. */
  109. <span id='Ext-PagingToolbar-cfg-displayInfo'> /**
  110. </span> * @cfg {Boolean} displayInfo
  111. * &lt;tt&gt;true&lt;/tt&gt; to display the displayMsg (defaults to &lt;tt&gt;false&lt;/tt&gt;)
  112. */
  113. <span id='Ext-PagingToolbar-cfg-pageSize'> /**
  114. </span> * @cfg {Number} pageSize
  115. * The number of records to display per page (defaults to &lt;tt&gt;20&lt;/tt&gt;)
  116. */
  117. pageSize : 20,
  118. <span id='Ext-PagingToolbar-cfg-prependButtons'> /**
  119. </span> * @cfg {Boolean} prependButtons
  120. * &lt;tt&gt;true&lt;/tt&gt; to insert any configured &lt;tt&gt;items&lt;/tt&gt; &lt;i&gt;before&lt;/i&gt; the paging buttons.
  121. * Defaults to &lt;tt&gt;false&lt;/tt&gt;.
  122. */
  123. <span id='Ext-PagingToolbar-cfg-displayMsg'> /**
  124. </span> * @cfg {String} displayMsg
  125. * The paging status message to display (defaults to &lt;tt&gt;'Displaying {0} - {1} of {2}'&lt;/tt&gt;).
  126. * Note that this string is formatted using the braced numbers &lt;tt&gt;{0}-{2}&lt;/tt&gt; as tokens
  127. * that are replaced by the values for start, end and total respectively. These tokens should
  128. * be preserved when overriding this string if showing those values is desired.
  129. */
  130. displayMsg : 'Displaying {0} - {1} of {2}',
  131. <span id='Ext-PagingToolbar-cfg-emptyMsg'> /**
  132. </span> * @cfg {String} emptyMsg
  133. * The message to display when no records are found (defaults to 'No data to display')
  134. */
  135. emptyMsg : 'No data to display',
  136. <span id='Ext-PagingToolbar-cfg-beforePageText'> /**
  137. </span> * @cfg {String} beforePageText
  138. * The text displayed before the input item (defaults to &lt;tt&gt;'Page'&lt;/tt&gt;).
  139. */
  140. beforePageText : 'Page',
  141. <span id='Ext-PagingToolbar-cfg-afterPageText'> /**
  142. </span> * @cfg {String} afterPageText
  143. * Customizable piece of the default paging text (defaults to &lt;tt&gt;'of {0}'&lt;/tt&gt;). Note that
  144. * this string is formatted using &lt;tt&gt;{0}&lt;/tt&gt; as a token that is replaced by the number of
  145. * total pages. This token should be preserved when overriding this string if showing the
  146. * total page count is desired.
  147. */
  148. afterPageText : 'of {0}',
  149. <span id='Ext-PagingToolbar-cfg-firstText'> /**
  150. </span> * @cfg {String} firstText
  151. * The quicktip text displayed for the first page button (defaults to &lt;tt&gt;'First Page'&lt;/tt&gt;).
  152. * &lt;b&gt;Note&lt;/b&gt;: quick tips must be initialized for the quicktip to show.
  153. */
  154. firstText : 'First Page',
  155. <span id='Ext-PagingToolbar-cfg-prevText'> /**
  156. </span> * @cfg {String} prevText
  157. * The quicktip text displayed for the previous page button (defaults to &lt;tt&gt;'Previous Page'&lt;/tt&gt;).
  158. * &lt;b&gt;Note&lt;/b&gt;: quick tips must be initialized for the quicktip to show.
  159. */
  160. prevText : 'Previous Page',
  161. <span id='Ext-PagingToolbar-cfg-nextText'> /**
  162. </span> * @cfg {String} nextText
  163. * The quicktip text displayed for the next page button (defaults to &lt;tt&gt;'Next Page'&lt;/tt&gt;).
  164. * &lt;b&gt;Note&lt;/b&gt;: quick tips must be initialized for the quicktip to show.
  165. */
  166. nextText : 'Next Page',
  167. <span id='Ext-PagingToolbar-cfg-lastText'> /**
  168. </span> * @cfg {String} lastText
  169. * The quicktip text displayed for the last page button (defaults to &lt;tt&gt;'Last Page'&lt;/tt&gt;).
  170. * &lt;b&gt;Note&lt;/b&gt;: quick tips must be initialized for the quicktip to show.
  171. */
  172. lastText : 'Last Page',
  173. <span id='Ext-PagingToolbar-cfg-refreshText'> /**
  174. </span> * @cfg {String} refreshText
  175. * The quicktip text displayed for the Refresh button (defaults to &lt;tt&gt;'Refresh'&lt;/tt&gt;).
  176. * &lt;b&gt;Note&lt;/b&gt;: quick tips must be initialized for the quicktip to show.
  177. */
  178. refreshText : 'Refresh',
  179. <span id='Ext-PagingToolbar-property-paramNames'> /**
  180. </span> * &lt;p&gt;&lt;b&gt;Deprecated&lt;/b&gt;. &lt;code&gt;paramNames&lt;/code&gt; should be set in the &lt;b&gt;data store&lt;/b&gt;
  181. * (see {@link Ext.data.Store#paramNames}).&lt;/p&gt;
  182. * &lt;br&gt;&lt;p&gt;Object mapping of parameter names used for load calls, initially set to:&lt;/p&gt;
  183. * &lt;pre&gt;{start: 'start', limit: 'limit'}&lt;/pre&gt;
  184. * @type Object
  185. * @property paramNames
  186. * @deprecated
  187. */
  188. <span id='Ext-PagingToolbar-property-pageSize'> /**
  189. </span> * The number of records to display per page. See also &lt;tt&gt;{@link #cursor}&lt;/tt&gt;.
  190. * @type Number
  191. * @property pageSize
  192. */
  193. <span id='Ext-PagingToolbar-property-cursor'> /**
  194. </span> * Indicator for the record position. This property might be used to get the active page
  195. * number for example:&lt;pre&gt;&lt;code&gt;
  196. * // t is reference to the paging toolbar instance
  197. * var activePage = Math.ceil((t.cursor + t.pageSize) / t.pageSize);
  198. * &lt;/code&gt;&lt;/pre&gt;
  199. * @type Number
  200. * @property cursor
  201. */
  202. initComponent : function(){
  203. var pagingItems = [this.first = new T.Button({
  204. tooltip: this.firstText,
  205. overflowText: this.firstText,
  206. iconCls: 'x-tbar-page-first',
  207. disabled: true,
  208. handler: this.moveFirst,
  209. scope: this
  210. }), this.prev = new T.Button({
  211. tooltip: this.prevText,
  212. overflowText: this.prevText,
  213. iconCls: 'x-tbar-page-prev',
  214. disabled: true,
  215. handler: this.movePrevious,
  216. scope: this
  217. }), '-', this.beforePageText,
  218. this.inputItem = new Ext.form.NumberField({
  219. cls: 'x-tbar-page-number',
  220. allowDecimals: false,
  221. allowNegative: false,
  222. enableKeyEvents: true,
  223. selectOnFocus: true,
  224. submitValue: false,
  225. listeners: {
  226. scope: this,
  227. keydown: this.onPagingKeyDown,
  228. blur: this.onPagingBlur
  229. }
  230. }), this.afterTextItem = new T.TextItem({
  231. text: String.format(this.afterPageText, 1)
  232. }), '-', this.next = new T.Button({
  233. tooltip: this.nextText,
  234. overflowText: this.nextText,
  235. iconCls: 'x-tbar-page-next',
  236. disabled: true,
  237. handler: this.moveNext,
  238. scope: this
  239. }), this.last = new T.Button({
  240. tooltip: this.lastText,
  241. overflowText: this.lastText,
  242. iconCls: 'x-tbar-page-last',
  243. disabled: true,
  244. handler: this.moveLast,
  245. scope: this
  246. }), '-', this.refresh = new T.Button({
  247. tooltip: this.refreshText,
  248. overflowText: this.refreshText,
  249. iconCls: 'x-tbar-loading',
  250. handler: this.doRefresh,
  251. scope: this
  252. })];
  253. var userItems = this.items || this.buttons || [];
  254. if (this.prependButtons) {
  255. this.items = userItems.concat(pagingItems);
  256. }else{
  257. this.items = pagingItems.concat(userItems);
  258. }
  259. delete this.buttons;
  260. if(this.displayInfo){
  261. this.items.push('-&gt;');
  262. this.items.push(this.displayItem = new T.TextItem({}));
  263. }
  264. Ext.PagingToolbar.superclass.initComponent.call(this);
  265. this.addEvents(
  266. <span id='Ext-PagingToolbar-event-change'> /**
  267. </span> * @event change
  268. * Fires after the active page has been changed.
  269. * @param {Ext.PagingToolbar} this
  270. * @param {Object} pageData An object that has these properties:&lt;ul&gt;
  271. * &lt;li&gt;&lt;code&gt;total&lt;/code&gt; : Number &lt;div class=&quot;sub-desc&quot;&gt;The total number of records in the dataset as
  272. * returned by the server&lt;/div&gt;&lt;/li&gt;
  273. * &lt;li&gt;&lt;code&gt;activePage&lt;/code&gt; : Number &lt;div class=&quot;sub-desc&quot;&gt;The current page number&lt;/div&gt;&lt;/li&gt;
  274. * &lt;li&gt;&lt;code&gt;pages&lt;/code&gt; : Number &lt;div class=&quot;sub-desc&quot;&gt;The total number of pages (calculated from
  275. * the total number of records in the dataset as returned by the server and the current {@link #pageSize})&lt;/div&gt;&lt;/li&gt;
  276. * &lt;/ul&gt;
  277. */
  278. 'change',
  279. <span id='Ext-PagingToolbar-event-beforechange'> /**
  280. </span> * @event beforechange
  281. * Fires just before the active page is changed.
  282. * Return false to prevent the active page from being changed.
  283. * @param {Ext.PagingToolbar} this
  284. * @param {Object} params An object hash of the parameters which the PagingToolbar will send when
  285. * loading the required page. This will contain:&lt;ul&gt;
  286. * &lt;li&gt;&lt;code&gt;start&lt;/code&gt; : Number &lt;div class=&quot;sub-desc&quot;&gt;The starting row number for the next page of records to
  287. * be retrieved from the server&lt;/div&gt;&lt;/li&gt;
  288. * &lt;li&gt;&lt;code&gt;limit&lt;/code&gt; : Number &lt;div class=&quot;sub-desc&quot;&gt;The number of records to be retrieved from the server&lt;/div&gt;&lt;/li&gt;
  289. * &lt;/ul&gt;
  290. * &lt;p&gt;(note: the names of the &lt;b&gt;start&lt;/b&gt; and &lt;b&gt;limit&lt;/b&gt; properties are determined
  291. * by the store's {@link Ext.data.Store#paramNames paramNames} property.)&lt;/p&gt;
  292. * &lt;p&gt;Parameters may be added as required in the event handler.&lt;/p&gt;
  293. */
  294. 'beforechange'
  295. );
  296. this.on('afterlayout', this.onFirstLayout, this, {single: true});
  297. this.cursor = 0;
  298. this.bindStore(this.store, true);
  299. },
  300. // private
  301. onFirstLayout : function(){
  302. if(this.dsLoaded){
  303. this.onLoad.apply(this, this.dsLoaded);
  304. }
  305. },
  306. // private
  307. updateInfo : function(){
  308. if(this.displayItem){
  309. var count = this.store.getCount();
  310. var msg = count == 0 ?
  311. this.emptyMsg :
  312. String.format(
  313. this.displayMsg,
  314. this.cursor+1, this.cursor+count, this.store.getTotalCount()
  315. );
  316. this.displayItem.setText(msg);
  317. }
  318. },
  319. // private
  320. onLoad : function(store, r, o){
  321. if(!this.rendered){
  322. this.dsLoaded = [store, r, o];
  323. return;
  324. }
  325. var p = this.getParams();
  326. this.cursor = (o.params &amp;&amp; o.params[p.start]) ? o.params[p.start] : 0;
  327. var d = this.getPageData(), ap = d.activePage, ps = d.pages;
  328. this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
  329. this.inputItem.setValue(ap);
  330. this.first.setDisabled(ap == 1);
  331. this.prev.setDisabled(ap == 1);
  332. this.next.setDisabled(ap == ps);
  333. this.last.setDisabled(ap == ps);
  334. this.refresh.enable();
  335. this.updateInfo();
  336. this.fireEvent('change', this, d);
  337. },
  338. // private
  339. getPageData : function(){
  340. var total = this.store.getTotalCount();
  341. return {
  342. total : total,
  343. activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
  344. pages : total &lt; this.pageSize ? 1 : Math.ceil(total/this.pageSize)
  345. };
  346. },
  347. <span id='Ext-PagingToolbar-method-changePage'> /**
  348. </span> * Change the active page
  349. * @param {Integer} page The page to display
  350. */
  351. changePage : function(page){
  352. this.doLoad(((page-1) * this.pageSize).constrain(0, this.store.getTotalCount()));
  353. },
  354. // private
  355. onLoadError : function(){
  356. if(!this.rendered){
  357. return;
  358. }
  359. this.refresh.enable();
  360. },
  361. // private
  362. readPage : function(d){
  363. var v = this.inputItem.getValue(), pageNum;
  364. if (!v || isNaN(pageNum = parseInt(v, 10))) {
  365. this.inputItem.setValue(d.activePage);
  366. return false;
  367. }
  368. return pageNum;
  369. },
  370. onPagingFocus : function(){
  371. this.inputItem.select();
  372. },
  373. //private
  374. onPagingBlur : function(e){
  375. this.inputItem.setValue(this.getPageData().activePage);
  376. },
  377. // private
  378. onPagingKeyDown : function(field, e){
  379. var k = e.getKey(), d = this.getPageData(), pageNum;
  380. if (k == e.RETURN) {
  381. e.stopEvent();
  382. pageNum = this.readPage(d);
  383. if(pageNum !== false){
  384. pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
  385. this.doLoad(pageNum * this.pageSize);
  386. }
  387. }else if (k == e.HOME || k == e.END){
  388. e.stopEvent();
  389. pageNum = k == e.HOME ? 1 : d.pages;
  390. field.setValue(pageNum);
  391. }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){
  392. e.stopEvent();
  393. if((pageNum = this.readPage(d))){
  394. var increment = e.shiftKey ? 10 : 1;
  395. if(k == e.DOWN || k == e.PAGEDOWN){
  396. increment *= -1;
  397. }
  398. pageNum += increment;
  399. if(pageNum &gt;= 1 &amp; pageNum &lt;= d.pages){
  400. field.setValue(pageNum);
  401. }
  402. }
  403. }
  404. },
  405. // private
  406. getParams : function(){
  407. //retain backwards compat, allow params on the toolbar itself, if they exist.
  408. return this.paramNames || this.store.paramNames;
  409. },
  410. // private
  411. beforeLoad : function(){
  412. if(this.rendered &amp;&amp; this.refresh){
  413. this.refresh.disable();
  414. }
  415. },
  416. // private
  417. doLoad : function(start){
  418. var o = {}, pn = this.getParams();
  419. o[pn.start] = start;
  420. o[pn.limit] = this.pageSize;
  421. if(this.fireEvent('beforechange', this, o) !== false){
  422. this.store.load({params:o});
  423. }
  424. },
  425. <span id='Ext-PagingToolbar-method-moveFirst'> /**
  426. </span> * Move to the first page, has the same effect as clicking the 'first' button.
  427. */
  428. moveFirst : function(){
  429. this.doLoad(0);
  430. },
  431. <span id='Ext-PagingToolbar-method-movePrevious'> /**
  432. </span> * Move to the previous page, has the same effect as clicking the 'previous' button.
  433. */
  434. movePrevious : function(){
  435. this.doLoad(Math.max(0, this.cursor-this.pageSize));
  436. },
  437. <span id='Ext-PagingToolbar-method-moveNext'> /**
  438. </span> * Move to the next page, has the same effect as clicking the 'next' button.
  439. */
  440. moveNext : function(){
  441. this.doLoad(this.cursor+this.pageSize);
  442. },
  443. <span id='Ext-PagingToolbar-method-moveLast'> /**
  444. </span> * Move to the last page, has the same effect as clicking the 'last' button.
  445. */
  446. moveLast : function(){
  447. var total = this.store.getTotalCount(),
  448. extra = total % this.pageSize;
  449. this.doLoad(extra ? (total - extra) : total - this.pageSize);
  450. },
  451. <span id='Ext-PagingToolbar-method-doRefresh'> /**
  452. </span> * Refresh the current page, has the same effect as clicking the 'refresh' button.
  453. */
  454. doRefresh : function(){
  455. this.doLoad(this.cursor);
  456. },
  457. <span id='Ext-PagingToolbar-method-bindStore'> /**
  458. </span> * Binds the paging toolbar to the specified {@link Ext.data.Store}
  459. * @param {Store} store The store to bind to this toolbar
  460. * @param {Boolean} initial (Optional) true to not remove listeners
  461. */
  462. bindStore : function(store, initial){
  463. var doLoad;
  464. if(!initial &amp;&amp; this.store){
  465. if(store !== this.store &amp;&amp; this.store.autoDestroy){
  466. this.store.destroy();
  467. }else{
  468. this.store.un('beforeload', this.beforeLoad, this);
  469. this.store.un('load', this.onLoad, this);
  470. this.store.un('exception', this.onLoadError, this);
  471. }
  472. if(!store){
  473. this.store = null;
  474. }
  475. }
  476. if(store){
  477. store = Ext.StoreMgr.lookup(store);
  478. store.on({
  479. scope: this,
  480. beforeload: this.beforeLoad,
  481. load: this.onLoad,
  482. exception: this.onLoadError
  483. });
  484. doLoad = true;
  485. }
  486. this.store = store;
  487. if(doLoad){
  488. this.onLoad(store, null, {});
  489. }
  490. },
  491. <span id='Ext-PagingToolbar-method-unbind'> /**
  492. </span> * Unbinds the paging toolbar from the specified {@link Ext.data.Store} &lt;b&gt;(deprecated)&lt;/b&gt;
  493. * @param {Ext.data.Store} store The data store to unbind
  494. */
  495. unbind : function(store){
  496. this.bindStore(null);
  497. },
  498. <span id='Ext-PagingToolbar-method-bind'> /**
  499. </span> * Binds the paging toolbar to the specified {@link Ext.data.Store} &lt;b&gt;(deprecated)&lt;/b&gt;
  500. * @param {Ext.data.Store} store The data store to bind
  501. */
  502. bind : function(store){
  503. this.bindStore(store);
  504. },
  505. // private
  506. onDestroy : function(){
  507. this.bindStore(null);
  508. Ext.PagingToolbar.superclass.onDestroy.call(this);
  509. }
  510. });
  511. })();
  512. Ext.reg('paging', Ext.PagingToolbar);</pre>
  513. </body>
  514. </html>