PDA

View Full Version : Ext.PagingToolbar - Which is the best way to disable/hide buttons?



Dumbledore
20 Nov 2010, 9:12 AM
Hi there,

is there a way to disable/hide buttons and elements (First, Last Buttons etc.) from a Pagingtoolbar or must i create my component which extends Ext.Toolbar?
I need a small pagingtoolbar with less functioniality...

Bye

Dumbledore
22 Nov 2010, 10:14 AM
ok, i see that my english is not so good and i must described my problem better:

I need a pagingtoolbar only the the previous/next buttons and a centered infotext. Can i use the Ext.Pagingtoolbar and overwrite initComponent or is it better to build a complete new component?

Bye...

Screamy
22 Nov 2010, 10:54 AM
I'm not claiming this to be the best (or even 'correct') solution, but it works:


var ptElements = Ext.query('em', Ext.getCmp('someGridId').getBottomToolbar().el.dom)
Ext.DomHelper.applyStyles(ptElements[0], {display: 'none'})
Ext.DomHelper.applyStyles(ptElements[3], {display: 'none'})
Ext.DomHelper.applyStyles(ptElements[4], {display: 'none'})
em 0 == First Page button
em 1 == Previous Page button
em 2 == Next Page button
em 3 == Last Page button
em 4 == Refresh button

Condor
23 Nov 2010, 6:18 AM
I would recommend:

var tb = new Ext.PagingToolbar({
initComponent: function(){
this.constructor.prototype.initComponent.call(this);
this.first.hide();
this.last.hide();
},
...
});

Dumbledore
24 Nov 2010, 3:27 AM
ok, nice... And Now for Something Completely Different :-)

Is it possible to center the displayInfo item?

i need something like

< Displaying {0} - {1} of {2} >

Condor
24 Nov 2010, 4:10 AM
Do you really need it centered, or is moving it next to the refresh button also an option?

var tb = new Ext.PagingToolbar({
initComponent: function(){
this.constructor.prototype.initComponent.call(this);
this.first.hide();
this.last.hide();
// Replace '->' with '-'
var ix = this.items.indexOf(this.displayItem) - 1;
this.items.removeAt(ix);
this.items.insert(ix, new Ext.Toolbar.Separator());
},
...
});

Dumbledore
24 Nov 2010, 4:35 AM
ok, now i see how to do that. Centered would be nice... What i really need is only 2 Buttons with the displayinfoand it sould be really thin like the image in the attachement

Condor
24 Nov 2010, 9:02 AM
Maybe you would be better off completely rewriting the initComponent method (have a look at the original PagingToolbar initComponent method).

Dumbledore
24 Nov 2010, 9:22 PM
ok, thanks!