-
15 May 2011 7:37 PM #1
Only show Paging Toolbar when appropriate
Only show Paging Toolbar when appropriate
Not sure if anyone is having the same problem but when using the Ext.plugins.ListPagingPlugin if you return a result set less than the page size the 'Load more...' still shows. Conversely, when you hit the last page the 'Load more...' doesn't disappear. The following override hides the paging plugin when not needed:
Code:Ext.override(Ext.plugins.ListPagingPlugin, { onListUpdate : function() { if (this.list.store && this.list.store.data.length < (this.list.store.currentPage * this.list.store.pageSize)) { if (!this.rendered) { return false; } else if (!this.autoPaging) { this.el.removeCls('x-loading'); this.el.remove(); } else { this.loading = false; } return false; } if (!this.rendered) { this.render(); } this.el.appendTo(this.list.getTargetEl()); if (!this.autoPaging) { this.el.removeCls('x-loading'); } this.loading = false; } });
-
17 May 2011 3:29 AM #2
Thanks for this. Works well for me. Have you added a bug report?
-
26 Jun 2011 1:43 PM #3
Worked for me as well. Definitely file a bug report with this as a patch. I'd like to nominate this post for a sticky.
My only gripe is that on the edge case where the total number of records is a multiple of the number of pages times the page size, the loading element appears one extra time because the app doesn't know yet that the server is at the end of the table.
-
26 Jun 2011 2:44 PM #4
-
27 Jul 2011 4:04 AM #5
@bwg & joel: Thanks! The edge case situation gave me some trouble.
-
16 Aug 2011 12:33 AM #6
I want to update the code a little bit. It will prevent the list store from calling nextPage() if the result less than the page size .
Code:Ext.override(Ext.plugins.ListPagingPlugin, { onListUpdate : function() { if (this.list.store && this.list.store.data.length < (this.list.store.currentPage * this.list.store.pageSize)) { if (!this.rendered) { return false; } else if (!this.autoPaging) { this.el.removeCls('x-loading'); this.el.remove(); } else { this.loading = false; } return false; } if (!this.rendered) { this.render(); } this.el.appendTo(this.list.getTargetEl()); if (!this.autoPaging) { this.el.removeCls('x-loading'); } this.loading = false; }, onScrollEnd : function(scroller, pos) { if (this.list.store && this.list.store.data.length < (this.list.store.currentPage * this.list.store.pageSize)) { return false; } if (pos.y >= Math.abs(scroller.offsetBoundary.top)) { this.loading = true; this.list.store.nextPage(); } } });
-
18 Aug 2011 7:28 PM #7
-
10 Nov 2011 5:39 AM #8
Hi,
I need help with this code. First, my whole json elements are returned plus a load more link at the bottom. Then, depending on the defined pagesize and my json length, when i click a certain number of time on the load more link it disapears wich i think is normal.
Can you help me show the correct numbers of elements that i define in the pageSize property please?
Here the code
Code:{ "profile": [{ "firstname": "firstname1", "lastname": "lastname1", "age": "1" },{ "firstname": "firstname2", "lastname": "lastname2", "age": "2" },{ "firstname": "firstname3", "lastname": "lastname3", "age": "3" }] }Code:Ext.setup({ onReady : function() { var jsonLink = 'http://127.0.0.1/Appsfan-v2/data.json'; var TPL = "{firstname} {lastname}"; Ext.override(Ext.plugins.ListPagingPlugin, { onListUpdate : function() { if(this.list.store && this.list.store.data.length < (this.list.store.currentPage * this.list.store.pageSize)) { console.log(this.list.store.pageSize) if(!this.rendered) { return false; } else if(!this.autoPaging) { this.el.removeCls('x-loading'); this.el.remove(); } else { this.loading = false; } return false; } if(!this.rendered) { this.render(); } this.el.appendTo(this.list.getTargetEl()); if(!this.autoPaging) { this.el.removeCls('x-loading'); } this.loading = false; }, onScrollEnd : function(scroller, pos) { if(this.list.store && this.list.store.data.length < (this.list.store.currentPage * this.list.store.pageSize)) { return false; } if(pos.y >= Math.abs(scroller.offsetBoundary.top)) { this.loading = true; this.list.store.nextPage(); } } }); var paging = new Ext.plugins.ListPagingPlugin({ autoPaging: false, loadMoreText: "More...", pullRefreshText: "MAJ", }) Ext.regModel('Profile', { fields : [{ name : 'firstname', type : 'string' }, { name : 'lastname', type : 'string' }, { name : 'age', type : 'number' }] }); var profileStore = new Ext.data.Store({ model : 'Profile', remoteFilter: true, pageSize: 1, proxy : { type : 'ajax', url : jsonLink, reader : { type : 'tree', root : 'profile' } }, autoLoad : true, }); //console.log(profileStore); var myList = new Ext.List({ itemTpl : TPL, store : profileStore, plugins : [paging] }); new Ext.Panel({ layout : 'card', fullscreen : true, items : [myList] }); } })
Similar Threads
-
Updating image on toolbar button and paging toolbar issues
By Jangla in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 9 Jul 2009, 1:21 AM -
Extjs paging toolbar for php paging
By speedytangent in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 29 Mar 2009, 2:14 PM -
Paging Toolbar Button (Show Details) issue
By 828 in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 13 Mar 2009, 11:57 AM -
[FIXED][3.x] Ext.form.ComboBox + Paging Toolbar errors when using remote paging
By jay@moduscreate.com in forum Ext 2.x: BugsReplies: 3Last Post: 15 Feb 2009, 4:54 PM -
Show paging grid in new window without paging for print
By extjs newbie in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 6 Aug 2008, 5:32 AM


Reply With Quote