PDA

View Full Version : I wish Ext.picker.Picker could use an Ext.NavigationBar as its toolbar



yoh.suzuki
30 Nov 2011, 1:35 PM
It would be nice to be able to center a title on the picker sheet, which would be possible with Ext.NavigationBar.

rdougan
30 Nov 2011, 4:11 PM
This should work:


Ext.create('Ext.Picker', {
toolbar: {
xtype: 'navigationbar',
title: 'Hello'
}
//other stuff....
});

yoh.suzuki
30 Nov 2011, 4:18 PM
Ah ha! Thanks! I tried it a different way and it didn't work so I assumed it wasn't supported. Out of curiosity, is my way incorrect?


Ext.create('Ext.Picker', {
toolbar: Ext.create('Ext.NavigationBar', {
title: 'Hello'
})
//other stuff....
});


It gave me the following message:

Uncaught TypeError: Object [object Object] has no method 'setShowTitle'

rdougan
30 Nov 2011, 4:21 PM
You have not added a 'docked' configuration, so it things the toolbar is one of the 'slots', and trying to call that method on it (which obviously doesn't exist). Add 'docked' and it will work.

yoh.suzuki
30 Nov 2011, 4:41 PM
I see. You are right, that works. The only difference between your code and mine is that I'm passing in an instance of Ext.NavigationBar instead of the config for Ext.NavigationBar. In my experience, normally these two actions are virtually identical.

Looking at the code, I now see what you are saying:


Ext.applyIf(config, {
docked: 'top'
});

... is inside of the function applyToolbar.

The only comment I have is that this is a little hidden / undocumented. My opinion is that either "docked:'top'" should be similarly required in the config and the configured instance (i.e. inferred in neither place), or they should both automatically receive it (i.e. inferred in both places), to eliminate confusion.

Thank you for your clarification and help.

rdougan
30 Nov 2011, 4:43 PM
I guess that make sense. Good work looking at the source.