-
26 May 2009 7:08 PM #1
How to center items in Ext.Toolbar
How to center items in Ext.Toolbar
Hi,
Items in toolbar are left by default, use '->' can make them right, but how to make them center?
My English is so poor. May I had expressed my trouble.
-
26 May 2009 7:55 PM #2
You need to get the toolbar object and wrap a center tag around it. I would suggest putting this code in 'render' listener for your toolbar object.
eg.
Code:var myToolbar = new Ext.Toolbar( { //config options listeners: { 'render':function(t) { t.getEl().child("table").wrap({tag:'center'}); } } });Jeremy Rayner
Software Engineer
-
26 May 2009 10:20 PM #3
-
26 May 2009 11:53 PM #4
Yep, that will work fine.
Just a heads up that in 3.0, it won't work as well.
A 3.0 Toolbar has two tables. One for left aligned Buttons and one for right aligned Buttons.
Also, a 3.0 Toolbar is a Container, and so will not contain the expected internal DOM structure until it's first layout operation.
So in 3.0:
Code:myToolbar.on('afterlayout', function(tb){ tb.el.child('.x-toolbar-right').remove(); var t = tb.el.child('.x-toolbar-left'); t.removeClass('x-toolbar-left'); t = tb.el.child('.x-toolbar-ct'); t.setStyle('width', 'auto'); t.wrap({tag: 'center'}); }, null, {single: true});Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
16 Jul 2009 12:51 AM #5
Hi,
Yes it works for extjs 3.0 but where is the paging info. Remove is'nt an option for me.
How can i make a fix for it.
-
9 Oct 2009 8:15 AM #6
Thanks for the workaround Animal. Any chance you guys have plans to simplify this via the toolbar config so that buttons can more easily be centered (which is a very common requirement)?
-
23 Feb 2010 2:20 AM #7
Hi,
I want to display in a tollbar a lef button a right button and a label in the middle. So i don't wanna remove left and right tool bars, but just to add another one between them, center aligned.
Or, maybe to simply add a label to left toolbar and align it right ?
What's the best solution ?
Thanks
-
23 Feb 2010 2:44 AM #8
A workaround would be to add a spacer between left button and title with width =toolbar width/2 but i'm not able to obtain toolbar width(maybe even is not defined until first layout render) . So what can i do ?
-
3 Jan 2013 12:35 AM #9


Reply With Quote