Ghostface
25 Apr 2011, 6:25 AM
Hi,
I am trying to get the items (List,Carousel etc.) displayed in a Panel wrapped inside a custom Template.
I basically want a box with a header around each item.
I tried to Extend the Container Layout and it gave me semi-good results. However I believe I am doing something wrong as i get duplicates of the widget* divs (i.e. 4 carousels in a panel will end up with 8 boxes, one wrapped around each carousel which is fine, and 4 empty ones).
If somebody could point out where I went wrong or if my approach entirely sucks and theres a prefered way of doing it please let me know.
Any help is appreciated.
Here is the code:
Ext.layout.Dashboard = Ext.extend(Ext.layout.ContainerLayout, {
/**
* @private
*/
type: "dashboard",
/**
* @private
*/
onLayout: function() {
Ext.layout.Dashboard.superclass.onLayout.call(this);
this.prepareItems();
},
/**
* @private
*/
prepareItems: function() {
var items = this.getLayoutItems(),
ln = items.length,
item, i;
for (i = 0; i < ln; i++) {
item = items[i];
item.doComponentLayout();
}
},
/**
* @private
*/
configureItem: function(item, position) {
var box=item.el.wrap({cls: 'widgetBox'});
item.el.wrap({cls: 'widgetBoxContent'});
item.el.wrap({cls: 'widgetBody'});
item.el.createChild({
html: 'test',//item.title,
cls: 'widgetBoxHeader'
},box.first());
},
renderItem: function(item, position, target) {
Ext.layout.Dashboard.superclass.renderItem.call(this, item, position, target);
}
});
Ext.regLayout("dashboard", Ext.layout.Dashboard);
I am trying to get the items (List,Carousel etc.) displayed in a Panel wrapped inside a custom Template.
I basically want a box with a header around each item.
I tried to Extend the Container Layout and it gave me semi-good results. However I believe I am doing something wrong as i get duplicates of the widget* divs (i.e. 4 carousels in a panel will end up with 8 boxes, one wrapped around each carousel which is fine, and 4 empty ones).
If somebody could point out where I went wrong or if my approach entirely sucks and theres a prefered way of doing it please let me know.
Any help is appreciated.
Here is the code:
Ext.layout.Dashboard = Ext.extend(Ext.layout.ContainerLayout, {
/**
* @private
*/
type: "dashboard",
/**
* @private
*/
onLayout: function() {
Ext.layout.Dashboard.superclass.onLayout.call(this);
this.prepareItems();
},
/**
* @private
*/
prepareItems: function() {
var items = this.getLayoutItems(),
ln = items.length,
item, i;
for (i = 0; i < ln; i++) {
item = items[i];
item.doComponentLayout();
}
},
/**
* @private
*/
configureItem: function(item, position) {
var box=item.el.wrap({cls: 'widgetBox'});
item.el.wrap({cls: 'widgetBoxContent'});
item.el.wrap({cls: 'widgetBody'});
item.el.createChild({
html: 'test',//item.title,
cls: 'widgetBoxHeader'
},box.first());
},
renderItem: function(item, position, target) {
Ext.layout.Dashboard.superclass.renderItem.call(this, item, position, target);
}
});
Ext.regLayout("dashboard", Ext.layout.Dashboard);