PDA

View Full Version : Best way to link grid/pagingtoolbar/store



rbastic
5 Jan 2011, 6:45 AM
Hello all,
I'm looking for a simple way to globally link a pagingtoolbar to it's given grid in my code. For instance, in some places I am doing this:


var grid = new ....;
grid.ptb = pagingtoolbar_obj;


So that elsewhere in the code I can say:



grid.ptb.moveFirst();


Now, I have many applications with many grids. I have a search object that links together with them as well.
I don't want to have to assign grid.ptb = ptb every time I create one.
Here are some other things I've tried:



globals['grid'].bbar.moveFirst(); // nope
globals['grid'].bbar[0].moveFirst(); // nope


I am of course storing the PagingToolbar in each grid's bbar object. I'm just wondering what methods to access it are available for me, or if there are any alternative approaches I should consider.

Thanks!
-Ryan

Condor
5 Jan 2011, 6:56 AM
Specifying ref:'ptb' in the PagingToolbar config should do that.

rbastic
5 Jan 2011, 7:09 AM
Specifying ref:'ptb' in the PagingToolbar config should do that.



var ptb = new Ext.PagingToolbar({
pageSize: parms['pageSize'],
displayInfo: true,
displayMsg: parms['displayMsg'],
emptyMsg: "",
store: userstore,
'ref': '../ptb'
});


Neither 'ref': 'ptb' nor 'ref': '../ptb' are acting as expected. Am I totally missing something obvious here?

rbastic
5 Jan 2011, 7:33 AM
I should mention -- this really isn't that big of a deal for me -- I can workaround this easily using manual assignment. Do you have to create the object within the context of another for 'ref' to work properly?

Condor
5 Jan 2011, 7:57 AM
Hmmm... You're correct, that doesn't work.

But this should:

globals['grid'].getBottomToolbar().moveFirst();