-
11 Apr 2012 6:47 AM #1
"List Paging" loses some records in list
"List Paging" loses some records in list
The problem is in the subject. I'm using plugin List Paging for my list. All was Ok until I decided to check data in list. And I've found that after the next page was loaded some records was absent. For example, I have pageSize = 10, but when I expect 20 records I see only 17.
I have checked store, but it has all 20 records and it looks like there is a bug in list or list paging plugin.
Model
StoreCode:Ext.define('MyApp.model.MyModel', { idProperty: 'Id', extend: 'Ext.data.Model', alias: 'model.MyModel', config: { fields: [{ name: 'Id', type: 'auto'}, { name: 'Name', type: 'string'}, { name: 'Phone', type: 'string'} ] } });
On beforeload I set some extra parameters for my web service (including my page parameters)Code:Ext.define('MyApp.store.MyJsonStore', { extend: 'Ext.data.Store', requires: [ 'MyApp.model.MyModel' ], config: { model: 'MyApp.model.MyModel', storeId: 'MyJsonStore', autoLoad: false, clearOnPageLoad: true, pageSize: 10, proxy: { type: 'ajax', headers: { 'Accept': 'application/json', 'Authorization': 'Basic ' + Ext.util.base64.encode('TestUser:UserPass') }, url: 'http://localhost:2376/WebApp/0/ServiceModel/EntityDataService.svc/AccountCollection?$select=Id,Name,Phone', reader: { type: 'json', rootProperty: 'd.results' } } } });
Function onBeforeLoadStoreCode:var store = Ext.getStore('MyJsonStore'); store.on('beforeload', onBeforeLoadStore);
When I made one change in ListPaging.js (took it SDK) the list showd 19 records (and it's not a solution at all), but I can't understand where it had lost record. Here is this change:Code:function onBeforeLoadStore(store, operation, options) { if (toResetCurrentPage) { store.currentPage = 1; } var currentPage = store.currentPage; var previousRecords = (currentPage > 1) ? (currentPage - 1) * 10 : 0; store.getProxy().setExtraParam("$top", 10); store.getProxy().setExtraParam("$skip", previousRecords); if (toResetCurrentPage) { toResetCurrentPage = false; } }
Please, help!Code:loadNextPage: function() { var store = this.getList().getStore(); this.setLoading(true); //keep a cache of the current scroll position as we'll need to reset it after the List is //updated with new data this.scrollY = this.getScroller().position.y; store.nextPage({ addRecords: true }); this.getList().refresh(); }
-
11 Apr 2012 9:36 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
We don't load the store, we use operation to load new records. This way we don't need to refresh the list, just update what needs to be updated.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
11 Apr 2012 9:49 AM #3
-
11 Apr 2012 11:35 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
I'm sorry. I got my threads mixed up, I had another thread asking about the PullRefresh plugin which my reply was meant for
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
11 Apr 2012 11:37 AM #5
-
11 Apr 2012 10:22 PM #6
Ideas?
Ideas?
Any ideas? Has anybody faced with it?
-
12 Apr 2012 1:20 AM #7
Ideas?
Ideas?
Any ideas? Has anybody faced with it?
-
12 Apr 2012 2:17 AM #8
add below override in a js file and load it after plugin file also remove on before load...that is not required
Ext.override(Ext.plugin.ListPaging, {
loadNextPage: function () {
var store = this.getList().getStore();
// add all proxy param here again
store.getProxy().setExtraParam('source', '');
this.setLoading(true);
//keep a cache of the current scroll position as we'll need to reset it after the List is
//updated with new data
this.scrollY = this.getScroller().position.y;
store.nextPage({ addRecords: true });
}
});
-
17 Apr 2012 9:13 AM #9
Did u get this working?
looks you are handling a odata feed.. i m using that too..
wouldn't be asier to just use the next link that's in the feed?
-
17 Apr 2012 9:52 AM #10
I solved it
I solved it
Yeah, I solved it. It was totally my fault. I added some extra divs for list items behind them, thats why ListPaging counted different numbers of shown elements on the page.
>>wouldn't be asier to just use the next link that's in the feed?
Frankly speaking, I don't know how to parse odata correctly using store.proxy (I mean how to get "next" link). If you have a code, it would be great.


Reply With Quote
