Search code examples
buttonsencha-touch-2toolbartitlebar

Sencha Touch 2 adding buttons to toolbar/titlebars


Can anyone tell me how I might add buttons, or other components, to a title/tool bar without using the items array? For months I've been struggling to find a way to make the bar on all my views contain the same user buttons and icons.

It's a struggle mostly on List item detail views where only a back button shows. I want the back button but also own buttons on the same bar. This is so my app has a uniform look and accessible functionality across the entire build.


Solution

  • Toolbar and TitleBar extend Ext.Container. In Sencha Touch containers always store their components inside the items array.

    If you want to have a toolbar that always look the same just create your own by extending Ext.Toolbar. Use the initialize method of such extended Toolbar to add the buttons/icons.

    To use it with a list you can create a wrapping container, which contains the extended toolbar and the list.