PDA

View Full Version : FormPanel+TabPanel submit only the active tab?



vagabondo23
27 May 2009, 5:52 AM
Hi at all , I need some help about the possibilities of submit only the active tab between different tab that has been rendered ,is it possible?
thanks in advance

27 May 2009, 9:02 AM
sure, quick solution: put a form panel in each tab, get the active, call it's getForm().submit() method.

samiswt
15 Oct 2012, 2:15 PM
I hope you've already got your answer. You know, I've been struggling to solve the same problem recently. When I did it and I'm trying to search a better solution in this forum. Please, everybody, share your ideas!

The problem may be in the ValidationStatus.js and the line number is 89.
this.basicForm.getFields().each(function(f) means get each field in your formpanel,even if your tab is hidden.

My idea is to set the hidden tab.disable(true) and it works.

Platform: Win 7 64-bit
Ext: ext-4.1.1a
WebServer: apache 2.2

/* my js code is below:*/
var fp = Ext.create('Ext.form.FormPanel', {
renderTo: Ext.getBody(),
id: 'status-form',
title: 'your title',
bodyStyle: 'padding:5px 5px 0 5px',
width: 630,
fieldDefaults: {
labelAlign: 'top',
msgTarget: 'side',
align: 'middle'
},
defaults: {
//border: false,
xtype: 'panel',
flex: 0
},

layout: 'hbox',
items: [
{
defaults: {
/*
*===================== To set the distance between the two tabs
*/
margin: '5 5 10 5'
},
items: [
tabsFrom,
tabsTo,
rbDateType,
ctDateTime
]
}
],
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
ui: 'footer',
items: ['->', {
text: 'Submit',
handler: function(){
var aTabFrom = Ext.getCmp('tabWhereFrom').getActiveTab();
// var aTabIdxFrom = Ext.getCmp('tabWhereFrom').items.findIndex('id', aTabFrom.id);
var iTabsFromCount = Ext.getCmp('tabWhereFrom').items.getCount();

var aTabTo = Ext.getCmp('tabWhereTo').getActiveTab();
// var aTabIdxTo = Ext.getCmp('tabWhereTo').items.findIndex('id', aTabTo.id);
var iTabsToCount = Ext.getCmp('tabWhereTo').items.getCount();

for(i = 0; i < iTabsFromCount; i++){
var aTab = Ext.getCmp('tabWhereFrom').items.get(i);
if(aTab != aTabFrom){
aTab.disable(true);
}
}

for(i = 0; i < iTabsToCount; i++){
var aTab = Ext.getCmp('tabWhereTo').items.get(i);
if(aTab != aTabTo){
aTab.disable(true);
}
}

if(fp.getForm().isValid()){
var sb = Ext.getCmp('form-statusbar');
sb.showBusy('searching...');
fp.getEl().mask();
alert('this is a test!');

}
else{
alert('error isValid!');
}

}
}]
},
Ext.create('Ext.ux.StatusBar', {
dock: 'bottom',
id: 'form-statusbar',
defaultText: 'Ready',
plugins: Ext.create('Ext.ux.statusbar.ValidationStatus', {form:'status-form'})
})]
});

samiswt
15 Oct 2012, 2:19 PM
by the way, even if you deleted the status bar, formpanel still tried to get all fields in it.