PDA

View Full Version : PagingToolBar: extension - add public method - goToPage()


jgarcia@tdg-i.com
10-20-2007, 03:12 PM
I didn't know what to call it, so i called it 'CustomToolBar'. i looked at the source, didn't see anything like it.


// Create user extensions namespace (Ext.ux)
Ext.namespace('Ext.ux');

Ext.ux.CustomToolBar = function(config) {
// call parent constructor
Ext.ux.CustomToolBar.superclass.constructor.call(this, config);

}

// extend
Ext.extend(Ext.ux.CustomToolBar, Ext.PagingToolbar, {
goToPage : function (pageNum) {
var d = this.getPageData();
pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
this.doLoad(pageNum * this.pageSize);
}
}); // end of extend


usage:
var paging = new Ext.ux.CustomToolBar ({your config data});
// Jump to page
paging.goToPage(int);

JeffHowden
10-21-2007, 03:18 PM
If the only reason you're extending the PagingToolbar is to add a new method to it, why not just use an override?

Ext.PagingToolbar.override({
goToPage : function (pageNum) {
var d = this.getPageData();
pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
this.doLoad(pageNum * this.pageSize);
}
});

jgarcia@tdg-i.com
10-21-2007, 08:56 PM
ack, you're right! meh! i forgot about .override :)

Thanks jeff. :)

JeffHowden
10-21-2007, 09:47 PM
Always happy to help (especially those with a much higher post count than mine ;)).

jgarcia@tdg-i.com
10-22-2007, 07:03 AM
Why are folks worried about post count around here?

JeffHowden
10-22-2007, 11:42 AM
No reason. I only brought it up cause I saw someone give you grief about it a few days ago. ;)

jgarcia@tdg-i.com
10-22-2007, 12:05 PM
http://www.xtremepccentral.com/forums/images/smilies/lolfall.gif good one. \:D/