bitdifferent
8 Jun 2007, 3:41 AM
If you want a toolbar attached to a grid, it's pretty easy:
var MyGrid = //grid definition here
var MyGridHeader = MyGrid.getView().getHeaderPanel(true);
var MyToolBar = new Ext.Toolbar ( MyGridHeader,
[ //buttons definition here, eg...
{ cls:'x-btn-text-icon',
icon: '/img/silk/add.png',
text: 'Add item',
handler: MyHandlerFunctionName //or an anonymous inline function
}
]
);
However, you can't do this in quite the same way with a TreePanel - it took me ages and eventually Bernard helped me out on IRC - and it's even simpler.
the html:
<div id="MyTreeContainer">
<div id="MyToolbarContainer"></div>
</div>
the js:
// building the treePanel
this.menuTree = new Ext.tree.TreePanel("MyTreeContainer"[...]); //normal tree definition
// building the toolbar
var tb = new Ext.Toolbar('MyToolbarContainer');
// adding a button
tb.addButton({text: "foo", id: 'foo', cls: 'x-btn-text-icon your-icon-class', handler: function(){alert("foo")}, scope: this});
This seems obvious now but I was putting a full borderlayout inside MyTreeContainer and then putting the TreePanel in a ContentPanel in a Region in a.... etc.
Thanks Bernard!
Matt S
var MyGrid = //grid definition here
var MyGridHeader = MyGrid.getView().getHeaderPanel(true);
var MyToolBar = new Ext.Toolbar ( MyGridHeader,
[ //buttons definition here, eg...
{ cls:'x-btn-text-icon',
icon: '/img/silk/add.png',
text: 'Add item',
handler: MyHandlerFunctionName //or an anonymous inline function
}
]
);
However, you can't do this in quite the same way with a TreePanel - it took me ages and eventually Bernard helped me out on IRC - and it's even simpler.
the html:
<div id="MyTreeContainer">
<div id="MyToolbarContainer"></div>
</div>
the js:
// building the treePanel
this.menuTree = new Ext.tree.TreePanel("MyTreeContainer"[...]); //normal tree definition
// building the toolbar
var tb = new Ext.Toolbar('MyToolbarContainer');
// adding a button
tb.addButton({text: "foo", id: 'foo', cls: 'x-btn-text-icon your-icon-class', handler: function(){alert("foo")}, scope: this});
This seems obvious now but I was putting a full borderlayout inside MyTreeContainer and then putting the TreePanel in a ContentPanel in a Region in a.... etc.
Thanks Bernard!
Matt S