PDA

View Full Version : PagingToolbar initial page



KajaSheen
31 Jan 2010, 11:15 AM
Right now I am moving from a Paging Memory Proxy for a grid to a JsonStore, that does remote loading. The application is as follows: The Grid displays the items, a click on a row loads a new page, displaying the Form to edit data, once saved the Grid is loaded again (new pageload).

I am using loadData on my JsonStore to display the values, so I am having not an extra AJAX request upon each displaying of the grid.

The problem now is that if I am editing an item on let's say the 3rd page, and I am saving it works fine that the grid displays the items from the third page, but as the PagingToolbar is newly loaded it is displaying "page 1"... Is there a possiblity to tell the PagingToolbar which the current cursor position should be upon creation? The documentation doesn't state anything like that.

Thanks,
Philipp

tobiu
31 Jan 2010, 11:50 AM
onLoad : function(store, r, o){
if(!this.rendered){
this.dsLoaded = [store, r, o];
return;
}
var p = this.getParams();
this.cursor = (o.params && o.params[p.start]) ? o.params[p.start] : 0;
var d = this.getPageData(), ap = d.activePage, ps = d.pages;

this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
this.inputItem.setValue(ap);
this.first.setDisabled(ap == 1);
this.prev.setDisabled(ap == 1);
this.next.setDisabled(ap == ps);
this.last.setDisabled(ap == ps);
this.refresh.enable();
this.updateInfo();
this.fireEvent('change', this, d);
}


i never tried it, but sending the param start of the current page with the new request could solve your problem, since it sets the cursor.

kind regards,
tobiu

KajaSheen
31 Jan 2010, 11:57 AM
Hey tobiu,

I am just looking at that part of the code. On the initial call the o param is an empty object (check function bindStore), and the JsonStore.loadData() does not allow to set these options, as opposed to the JsonStore.load(), so right now I can either override the PagingToolbar.onLoad() to accept a seperate start param, or override the JsonStore.loadData, to pass an options parameter to the load event handler...

Out of my mind I would prefer to override the PagingToolbar... ;)

tobiu
31 Jan 2010, 12:42 PM
you definitely can add params / baseParams to a store, so that they get send with each time. use the event onBeforeLoad (or similar), update the value for start and it should work.

kind regards,
tobiu

ishobr
31 Jan 2010, 12:46 PM
The problem now is that if I am editing an item on let's say the 3rd page, and I am saving it works fine that the grid displays the items from the third page, but as the PagingToolbar is newly loaded it is displaying "page 1"... Is there a possiblity to tell the PagingToolbar which the current cursor position should be upon creation? The documentation doesn't state anything like that.


If you just want to display the same page use store.reload() method instead.


Ihsan

KajaSheen
1 Feb 2010, 11:33 AM
If you just want to display the same page use store.reload() method instead.


Ihsan

The Problem is that I display the third page of the grid => Click on an item does a page reload (completly different layout because of the form) => Save Close does again a page reload which know that the user was on the third page, thus displaying the data, but not for the PagingToolbar, without actually requesting the data again via a load(start: 50, limit: 25) i.e.

But I don't want that additional load call, because the data is already there, I just want to tell the PagingToolbar that it should point to page 3...