-
19 Mar 2012 12:19 PM #1
Navigation View Title (IPad App)
Navigation View Title (IPad App)
Hi,
On a tap of item, how to set the title of the Navigation View dynamically?
For e.g.: The item value which I have selected, I want to set the same value on the title of Navigation View.
How can I do it?
-
19 Mar 2012 12:21 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
It will use the title of the item being pushed.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
5 Apr 2012 11:27 AM #3
Dynamically...
Dynamically...
But what if you want to set the title dynamically?
For example, inside a controller:
The SomeContainerView is an 'Ext.Container', which does not have a 'setTitle()' method.Code:this.getMyNavigationView().push({xtype : 'someContainerView'});
So I find myself doing
Is there a better way around this? It doesn't quite feel rightCode:this.getSomeContainerView().config.title = record.get('title');
Thanks for any ideas!!
Brad
-
5 Apr 2012 11:42 AM #4
Solved
Solved
Shoot...my apologies,
this works:
Thanks again!Code:this.getMyViewport().push({ xtype : 'myContainer', title : record.get('title') });
Brad
-
5 Apr 2012 12:35 PM #5
-
10 Apr 2012 7:30 AM #6
What if the view is already pushed and you are popping back to it after a store reload and want to change the title?
How would that be done?
Worth
-
11 Apr 2012 5:06 PM #7
This kind of works.
This kind of works.
I'm trying to get something to work but haven't quite been able to. Here's some code.
A NavigationView, Panel (testviewone) to be initially pushed, and another Panel (testviewtwo) to be pushed and popped via a button in view one.
Finally a controller for all the logic.Code:Ext.define('MyApp.view.util.TestView', { extend : 'Ext.NavigationView', alias : 'widget.testview', }); Ext.define('MyApp.view.util.TestViewOne', { extend : 'Ext.Panel', alias : 'widget.testviewone', config : { html : 'Test View One', items : [ { xtype : 'button', id : 'newviewbutton', text : 'View Two', } ] } }); Ext.define('MyApp.view.util.TestViewTwo', { extend : 'Ext.Panel', alias : 'widget.testviewtwo', config : { html : 'Test View Two', } });
Code:Ext.define('MyApp.controller.TestController', { extend : 'Ext.app.Controller', requires : [ 'MyApp.view.util.TestViewOne', 'MyApp.view.util.TestViewTwo' ], config : { refs : { testView : 'testview', testViewOne : 'testviewone', testViewTwo : 'testviewtwo', newViewButton : 'testviewone #newviewbutton' }, control : { testView : { show : 'pushViewOne', pop : 'changetestviewtitle', }, newViewButton : { tap : 'pushViewTwo' } } }, pushViewOne : function() { this.getTestView().push({ xtype : 'testviewone', title : 'Test View One', }); }, pushViewTwo : function() { console.log('Pushing View'); this.getTestView().push({ xtype : 'testviewtwo', title : 'Brand New Title' }); }, changetestviewtitle : function() { console.log('Changing test view title'); this.getTestViewOne().config.title = 'New One!'; this.getTestViewOne().setHtml('New HTML!'); } });
Open and click the button to push testviewtwo, then pop with the back button. Now in your developer console run 'Ext.ComponentQuery.query('testviewone');'.
Notice the config.title="New One!" but t is not reflected in the title bar. I don't think I would call this a bug because the title attribute is not advertised as public or settable, but more control over the title attribute would be really nice.
Brad
-
11 Apr 2012 5:28 PM #8
I've figured this out today but don't have access to my code tonight.
It went something like this:
My views were just containers and I added a title bar to them.Code:getView().query('titlebar')[0].setTitle('newTitle);
If the component already has a title, is there already a "titlebar" to query for and then set the title?
I'll try to send more information tomorrow.
Worth
-
12 Apr 2012 2:02 AM #9
add this override
Ext.override(Ext.navigation.Bar, {
getNavigationBarProxyProperties: function () {
return {
title: {
left: this.proxy.titleComponent.renderElement.getLeft()
},
backButton: {
left: this.proxy.backButton.renderElement.getLeft(),
width: this.proxy.backButton.renderElement.getWidth()
}
};
}
});
and get the bar like this and set title dynamically
var bar = mainViewComponent.getNavigationBar();
bar.titleComponent.setTitle('dynamic title');
-
28 Apr 2012 6:29 PM #10
I used this to get it working:
via: Joeri Sebrechts
Code:var bar = this.getMain().getNavigationBar(); if (bar.titleComponent.element) bar.titleComponent.element.setWidth('auto'); bar.titleComponent.setTitle(title); bar.refreshProxy();


Reply With Quote