PDA

View Full Version : adding FormPanel to Tab - problem



uki
27 Aug 2010, 7:36 AM
Hi,
I have problem with adding form panel into tab. In west region I have tree with context menu. When I run add handler, I've got en error - this.body is null.

How can I add this form panel into tab? I missed some config options?


function addHandler() {
var dn = new String(tree.getSelectionModel().getSelectedNode());
dn = (dn.replace("]","")).slice(6);

var TabPanel = Ext.getCmp('center-tab');
var addtab = TabPanel.getItem(dn);

if(addtab){
TabPanel.setActiveTab(addtab);
} else {
newTabPanel(dn);
}
}

function newTabPanel(dn){

var groupDetailsForm = new Ext.form.FormPanel({
defaultType: 'textfield',
border: false,
items: [{
name: 'groups[cn]',
fieldLabel: 'cn',
allowBlank: false
},{
name: 'groups[gidNumber]',
fieldLabel: 'gidNumber',
allowBlank: false,
},{
name: 'groups[objectclass][]',
value: 'top',
xtype: 'hidden'
},{
name: 'groups[objectclass][]',
value: 'posixGroup',
xtype: 'hidden'
}]
});

if(dn.toLowerCase()=='ou=groups,dc=example,dc=com'){
var addForm = new Ext.form.FormPanel({
url: './modules/ldap/f_add.php',
id: 'addFormGroup',
width: 600,
items: [{
xtype: 'tabpanel',
activeTab: 0,
defaults:{bodyStyle: 'padding:10px'},
items: [{
title: 'Group Details',
layout: 'form',
id: 'addFormGroupD',
height: 400,
items: [ groupDetailsForm ]
},{
title: 'Group Members',
layout: 'form',
height: 400
//items: [ groupMembersForm ]
}],
buttons: [{
text: 'Save',
handler: function(){
addForm.getForm().submit({
success: function(f,a){
Ext.Msg.alert('Success', 'Group added successfully');
var TabPanel = Ext.getCmp('center-tab');
var addtab = TabPanel.getItem(dn);
TabPanel.remove(addtab);
tree.getLoader().load(tree.root);
},
failure: function(f,a){
if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
Ext.Msg.alert('Failure', 'Server reported:'+a.response.status+' '+a.response.statusText);
}
if (a.failureType === Ext.form.Action.SERVER_INVALID){
Ext.Msg.alert('Warning', a.result.errormsg);
}
}
});
}
},{
text: 'Reset',
handler: function(){
addForm.getForm().reset();
}
}]
}]
});

}

var newAddTab = Ext.getCmp('center-tab');
newAddTab.add({
title: 'Add to ' + dn,
closable: true,
id: dn,
bodyStyle: 'padding:15px',
items: [ addForm ]
}).show();
newAddTab.doLayout();
}




22162

Thx
Uki