kostik83
7 Jul 2010, 7:49 AM
Hi, I would like to accomplish a trivial task but it doesn't seem to work. I have main JS file which builds top navigation bar and main layout panel, then I generate new items with PHP and place them in the panel. What I am having problem with is rendering those items on the screen.
here is the main.js file which is included at the top:
Ext.setup({
glossOnIcon: false,
onReady: function() {
this.refreshButton = new Ext.Button({
hidden: false,
text: 'R',
ui: 'action',
handler: function () {
this.redirect(C.BASE);
},
scope: this
});
this.logoutButton = new Ext.Button({
text: 'Logout',
ui: 'action',
hidden: false,
handler: this.onLogoutButtonTap,
scope: this
});
this.backButton = new Ext.Button({
hidden: true,
text: 'Back',
ui: 'back',
handler: this.onBackButtonTap,
scope: this
});
this.menuButton = new Ext.Button({
hidden: true,
text: 'Menu',
ui: 'normal',
handler: this.onMenuButtonTap,
scope: this
});
this.spacer = {
xtype:'spacer',
flex:1
};
this.navigationButtons = [this.backButton, this.spacer, this.menuButton, this.spacer, this.logoutButton];
if (C.DEBUG) {
this.navigationButtons.unshift(this.spacer);
this.navigationButtons.unshift(this.refreshButton);
}
this.navigationBar = new Ext.Toolbar({
ui: 'dark',
dock: 'top',
items: this.navigationButtons
});
new Ext.Panel({
id: 'layout',
fullscreen: true,
layout: {
type: 'fit'
},
defaults: {
flex: 1
},
dockedItems: this.navigationBar,
items: {}
});
}
});Now, when i build the page I place the following code:
<script type='text/javascript'>
Ext.onReady(function() {
var form = new Ext.form.FormPanel({
id: 'my-form',
scroll: 'vertical',
items: [{xtype: "field",inputType: "hidden",name: "submit",id: "submit",value: "1"}
,{xtype : "fieldset", items : [{
text: 'Button 1',
ui: 'action',
xtype: 'button',
handler: function(obj, evt) {
//something
}
,{
text: 'Button 2',
ui: 'action',
xtype: 'button',
handler: function(obj, evt) {
//something
}
]}]});
var panel = new Ext.Panel({
layout: {
type: 'fit'
},
defaults: {
flex: 1
},
items: form,
});
var layout = Ext.getCmp('layout');
layout.items = panel;
layout.doLayout();
</script>
Unfortunately this does not work, it only renders dockedItems. What do i need to call (i guess instead of layout.doLayout()) so the items in layout are displayed.
Thanks,
Kostik
here is the main.js file which is included at the top:
Ext.setup({
glossOnIcon: false,
onReady: function() {
this.refreshButton = new Ext.Button({
hidden: false,
text: 'R',
ui: 'action',
handler: function () {
this.redirect(C.BASE);
},
scope: this
});
this.logoutButton = new Ext.Button({
text: 'Logout',
ui: 'action',
hidden: false,
handler: this.onLogoutButtonTap,
scope: this
});
this.backButton = new Ext.Button({
hidden: true,
text: 'Back',
ui: 'back',
handler: this.onBackButtonTap,
scope: this
});
this.menuButton = new Ext.Button({
hidden: true,
text: 'Menu',
ui: 'normal',
handler: this.onMenuButtonTap,
scope: this
});
this.spacer = {
xtype:'spacer',
flex:1
};
this.navigationButtons = [this.backButton, this.spacer, this.menuButton, this.spacer, this.logoutButton];
if (C.DEBUG) {
this.navigationButtons.unshift(this.spacer);
this.navigationButtons.unshift(this.refreshButton);
}
this.navigationBar = new Ext.Toolbar({
ui: 'dark',
dock: 'top',
items: this.navigationButtons
});
new Ext.Panel({
id: 'layout',
fullscreen: true,
layout: {
type: 'fit'
},
defaults: {
flex: 1
},
dockedItems: this.navigationBar,
items: {}
});
}
});Now, when i build the page I place the following code:
<script type='text/javascript'>
Ext.onReady(function() {
var form = new Ext.form.FormPanel({
id: 'my-form',
scroll: 'vertical',
items: [{xtype: "field",inputType: "hidden",name: "submit",id: "submit",value: "1"}
,{xtype : "fieldset", items : [{
text: 'Button 1',
ui: 'action',
xtype: 'button',
handler: function(obj, evt) {
//something
}
,{
text: 'Button 2',
ui: 'action',
xtype: 'button',
handler: function(obj, evt) {
//something
}
]}]});
var panel = new Ext.Panel({
layout: {
type: 'fit'
},
defaults: {
flex: 1
},
items: form,
});
var layout = Ext.getCmp('layout');
layout.items = panel;
layout.doLayout();
</script>
Unfortunately this does not work, it only renders dockedItems. What do i need to call (i guess instead of layout.doLayout()) so the items in layout are displayed.
Thanks,
Kostik