-
8 Feb 2009 5:27 PM #21
Condor, how would I be able to get the entire data set locally if needed. I'm trying to export the data in the Ext.ux.PagingStore to excel, but I only get the the page which is shown to the user as expected.
Can you please let me know if this is possible? Though I could find out if this was possible with with the PagingStore's parent class.
Thanks in advance..
-
9 Feb 2009 7:14 AM #22
Got closer to completing this. So issue lies when calling the getTotalCount() from the PagingStore.
this.store.getCount() = returns the size of the current page loaded in the grid and not the total number of records in the store as based on it's parent's implementation of getTotalCount().
So instead of calling store.getCount(), I was able to get the total size of dataset by doing
And it returned the full data set size.Code:this.store.allData.items.length
Last edited by whodat; 9 Feb 2009 at 7:24 AM. Reason: Solved it.
-
9 Feb 2009 7:33 AM #23Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Yes, this.store.allData is a MixedCollection that contains all records.
You can use it to export all data to Excel (the default code expects a store, but it can easily be changed to a MixedCollection).
-
10 Feb 2009 7:27 AM #24
Condor is this used anytime new records are reloaded or only when you add records to the store?
One of the issues I noticed is, when the store is originally loaded with lets say 100 records showing 20 per page (so 5 pages).
I then reload the store while I'm on page 3, 4, or 5 and there are only 40 records still showing 20 per page. The paging tool bar doesn't update correctly.
By not updating correctly, it shows nothing in the grid since I am page 3, but I have the previous page option allows me to paginate to page 2 and then grid shows the 20 records.
My question is, do I need to add a listener for reload and call applyPaging()?
-
10 Feb 2009 7:58 AM #25Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
That is something that is not properly handled by PagingStore.
Could you try if this fixes it:
Code:Ext.override(Ext.ux.data.PagingStore, { loadRecords : function(o, options, success){ if(!o || success === false){ if(success !== false){ this.fireEvent("load", this, [], options); } if(options.callback){ options.callback.call(options.scope || this, [], options, false); } return; } var r = o.records, t = o.totalRecords || r.length; if(!options || options.add !== true){ if(this.pruneModifiedRecords){ this.modified = []; } for(var i = 0, len = r.length; i < len; i++){ r[i].join(this); } if(this.allData){ this.data = this.allData; delete this.allData; } if(this.snapshot){ this.data = this.snapshot; delete this.snapshot; } this.data.clear(); this.data.addAll(r); this.totalLength = t; this.applySort(); if(!this.allData){ this.applyPaging(); } if(r.length != this.getCount()){ r = [].concat(this.data.items); } this.fireEvent("datachanged", this); }else{ this.totalLength = Math.max(t, this.data.length+r.length); this.add(r); } options[this.paramNames.start] = this.start; this.fireEvent("load", this, r, options); if(options.callback){ options.callback.call(options.scope || this, r, options, true); } }, applyPaging : function(){ var start = this.start, limit = this.limit; if((typeof start == 'number') && (typeof limit == 'number')){ var allData = this.data, data = new Ext.util.MixedCollection(allData.allowFunctions, allData.getKey); if(start >= allData.getCount()){ start = this.start = allData.getCount() ? Math.floor((allData.getCount() - 1) / limit) : 0; } data.items = allData.items.slice(start, start + limit); data.keys = allData.keys.slice(start, start + limit); var len = data.length = data.items.length; var map = {}; for(var i = 0; i < len; i++){ var item = data.items[i]; map[data.getKey(item)] = item; } data.map = map; this.allData = allData; this.data = data; } } });
-
10 Feb 2009 9:07 AM #26
-
10 Feb 2009 10:55 AM #27
Is there somewhere significant I should place this code?
I placed it right afterin the original PagingStore class.Code:Ext.extend(Ext.ux.data.JsonPagingStore, Ext.ux.data.PagingStore);
It doesn't seem to update the current page or the "Displaying parts " text.
I have attached a screenshot. Unless you tell me I have placed your updated code in the wrong place.
Please let me know Condor and thanks for your help.
Just to clarify, I orginally loaded the store with 12 records, then reloaded the store again with 9 records while on the 2nd page of the first dataset.
-
10 Feb 2009 11:10 AM #28
Live exalpme please!!
Greetings,
-
10 Feb 2009 11:16 AM #29
What did to correct this problem was the following:
When I called reload to update the store with the new records.. I called reload with the following params
ds.reload({params:{start: 0, limit: 10}});
And everything was solved, the pages reloaded correctly.. Maybe not exactly the behavior you intended but for my users it will work.
Thanks for the help.
-
10 Feb 2009 11:20 PM #30Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
The change I suggested should made sure that if you request a page that isn't in the dataset, the last page is shown instead.
But if you already know you are forced reloading the data then you should indeed select the first page (as you do now).



Reply With Quote