Note that there are some explanatory texts on larger screens.

plurals
  1. POToolbar items added/inserted into Ext.ToolBar aren't showing on the page
    primarykey
    data
    text
    <p>I have a custom component that extends a panel. The panel has a top tool bar with a basic config. I want to be able to add items to the panel dynamically after it has been created.</p> <p>Those items should always come at the end of the main set of menu items and before the filler that pushes the logout button to the far right, so I wrote the insertMenuItem function to grab the position of the "shunt" (the tbfill) item and insert the new toolbar item at this location. If it doesn't find the "shunt", because its been overridden, it just adds to the end of the toolbar.</p> <p>This seems to work just great. If I look at the "live" contentPanel I can see the inserted menu item. The problem come with getting it to display. Now I suspect that this is a scoping issue, I'm just not sure what, where, when, how.... :|</p> <p>I've tried this.doLayout(), topToolbar.doLayout() in the function I've got a doLayout() on the contentPanel object after calling my function, but none of them seem to help.</p> <p>HELP! ;-D</p> <p>Below is my extended Panel class. Thanks in advance for your help</p> <p>Stephen</p> <pre> SOM.ux.contentPanel = Ext.extend(Ext.Panel, { autoScroll:true ,initComponent:function() { var config = { plugins:['dispatcher'] ,contentEl : Ext.get('som-body') ,tbar:{ itemId:'contenttoolbar' ,items:[ { xtype : 'button', text: 'Dashboard', handler: function(){ document.location.href = '/' } },{itemId:'shunt',xtype: 'tbfill'},{ xtype : 'button', text: 'Logout', handler: function(){ document.location.href = '/admin.login.doLogout' } },{ xtype : 'tbbutton', text: 'Message', scope: this, handler: function(){ this.publish('SOM.ux.Dashboard',{action:'doHelloWorld',params:{name:'Stephen'}}); } } ] } }; // end of config Ext.apply(this, Ext.apply(this.initialConfig, config)); SOM.ux.contentPanel.superclass.initComponent.apply(this, arguments); } ,afterRender: function(){ this.subscribe('SOM.ux.Toolbar'); SOM.ux.contentPanel.superclass.afterRender.call(this); } ,onDispatchMessage: function(subject,message) { if (message.action) { this[message.action].call(this,message.params); } console.log('contentpanel doDispatch',subject,message); } ,insertMenuItem: function(itemObj){ var topToolbar = this.getTopToolbar(); var aItems = topToolbar.items; var insertPos = aItems.indexOfKey('shunt'); if (insertPos) { console.log('using insert'); topToolbar.insert(insertPos,itemObj); } else { console.log('using add'); topToolbar.add(itemObj); } this.getTopToolbar().doLayout(); } </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload