Use initItems() and changePage(0, {refresh:true}) where you would normally use changeDataset() if you weren't using a pager.
Pass in enough items to initItems() for a page in the grid and specify the total number of rows in ALL of the pages...not just the first one. That will get things started. After that, the pager will call your callback function when it needs data and will tell you through the parameters which "pages" of data it needs. Your callback function should request the data and then when the response comes back from the server you call the pager's onGotPage().
Thanks for your reply d_caveney. I tried your suggestions, of calling initItems() and providing the first chuck of data to the pager. Also used changePage(0, {refresh:true}) inside updateView instead of changeDataset(). Now, this is whats is happening:
1. First the grid opens with no data and is blank, then when i try to scroll to the next page from the pageIndicator, the data is displayed. It shows only 10 pages, but I am able to scroll to only the 7th page.
2. Also, the callback method which we pass in the pager constructor, never gets called, which should be getting called again and again. This is how I have constructed the pager:
CODE
// Pager declared in create view
var pageSize = 5;
var fetchSize = 50;
var howMany = 3;
fetchParams = {'page':1, 'per_page':5};
pager = new KONtx.utility.Pager(pageSize, fetchSize, this.fetchData, this, howMany);
// After I get the first chuck of data
pager.initItems(arr,arr.length);
// fetchData :function(){
// fetch chuck of data again
var request = new XMLHttpRequest();
request.onreadystatechange = this.fetchResp;
request.open( "POST", baseListUrl, true);
request.setRequestHeader( "Content-type", "text/xml; charset=utf-8");
request.setRequestHeader( "SOAPAction", "xxxxxxxxxx");
request.setRequestHeader( "Content-Length", request.length);
var timeout = 30;
request.timeout = timeout;
request.fetchParams = fetchParams;
request.pager = pager;
request.send( request);
}
fetchResp : function(){
// Parser the response
// call onGotPage() func
pager.onGotPage(fetchParams,pagerDataArray, pagerDataArray.length);
}
// Inside UpdateView
this.controls.grid.changePage(0, {refresh:true});
I am stuck with pager for quite a few days now. Please help with where I am goin wrong. Some code would really help.
Thanks,
Sougata.