title: How to add Tools dynamically in an Ext Js window?
body: <p>I wanto to add a tool (search, help, gear, ...) in a window dynamically, like this:
  <a href="http://www.rahulsingla.com/sites/default/files/content/blog/extjs/extjs-panel-add-tool.htm" rel="nofollow">http://www.rahulsingla.com/sites/default/files/content/blog/extjs/extjs-panel-add-tool.htm</a></p>
  
  <p><strong>And I need to create more than one instance of UIMyWindow at the same time.</strong></p>
  
  <p>However, I'm using Ext Designer which generates 2 files:</p>
  
  <ul>
  <li>MyWindow.ui.js: class declaration.</li>
  <li>MyWindow.js: methods implementation.</li>
  </ul>
  
  <p>Besides Ext Designer hasn't an option Tools at design time (I didn't find).</p>
  
  <p>I was adding the tool outside MyWindow.js and MyWindow.ui.js, like this:</p>
  
  <pre><code>var winMyWindow = new UIMyWindow({
      autoShow: 'true', 
      tools: [{
                 type:'gear',
                 handler: function(){
                     // Some code...
                 }
      }]
  });
  </code></pre>
  
  <p>But I want to put this block inside MyWindow.js. So, I did this:</p>
  
  <pre><code>UIMyWindow = Ext.extend(UIMyWindowUi, {
      tools: [{
                 type:'gear',
                 handler: function(){
                     // Some code...
                 }
      }],
  
  initComponent: function() {
     UImenuDock.superclass.initComponent.call(this);
  </code></pre>
  
  <p>If you ask me "Why not to put this code inside MyWindow.ui.js?", I would answer "because I don't want to put this code manually every time I make changes in the design file (Ext Designer)".</p>
  
  <p>Well, if I open one window, it's seems work ok, but if I open a second at the same time, the tools are duplicated in the second window...</p>
  
  <p>So, any idea how to add tools dynamically in MyWindow.js in this specific case?</p>