PDA

View Full Version : "List Paging" loses some records in list



s.t.a.s
11 Apr 2012, 6:47 AM
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


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'}
]
}
});


Store


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'
}
}
}
});


On beforeload I set some extra parameters for my web service (including my page parameters)


var store = Ext.getStore('MyJsonStore');
store.on('beforeload', onBeforeLoadStore);


Function onBeforeLoadStore


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;
}
}


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:


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();
}


Please, help!

mitchellsimoens
11 Apr 2012, 9:36 AM
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.

s.t.a.s
11 Apr 2012, 9:49 AM
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.

But how to update? And what event I should use for it?
Honestly, I thought store.nextPage() in ListPaging does it automatically. And it looks like it really does but incorrectly in my case.

mitchellsimoens
11 Apr 2012, 11:35 AM
I'm sorry. I got my threads mixed up, I had another thread asking about the PullRefresh plugin which my reply was meant for

s.t.a.s
11 Apr 2012, 11:37 AM
:(

s.t.a.s
11 Apr 2012, 10:22 PM
Any ideas? Has anybody faced with it?

s.t.a.s
12 Apr 2012, 1:20 AM
Any ideas? Has anybody faced with it?

tarun_juneja@hotmail.com
12 Apr 2012, 2:17 AM
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 });

}
});

Rui Marinho
17 Apr 2012, 9:13 AM
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?

s.t.a.s
17 Apr 2012, 9:52 AM
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.

Rui Marinho
17 Apr 2012, 10:05 AM
ok so to get that info i did:

config: { autoLoad: true, model: 'Remax.model.Angariacao', nextPage: null,
currentTotal: null} listeners: { load: function (store, records, successful) { store.nextPage = store.getProxy().getReader().rawData.d.__next; store.currentTotal = store.getProxy().getReader().rawData.d.__count;}

you also have to put the &inlinecount=allpages in your odata url if you want to get the count of that resource set..

Rui Marinho
17 Apr 2012, 10:08 AM
this works great better if you are doing infinite scroll.. imo

when the user is in the end of the list, we check if we have a next link.. if we do.. we load that link.. what i m missing now is merging the records.. looking at it now.

After reading some posts it seems this is a request that more people ahve, to load paging data via odata... since this is a standard method i really thin there should be a offical proy for Odata, embrce standards!