PDA

View Full Version : Problems with verification of data on tabpanel



dvelopp
17 Jan 2011, 6:27 AM
Good day!
Studying ExtJS I have following problem:
I can not organize the verification of data in tabpanel. On this there is a reason - I have no ID, the panel on which I could reference.
Here's how I did it:

Ext.onReady(function() {
var win = new Ext.Window({
width:500,
height:350,
closable:false,
autoScroll:true,
title: 'Register',
html:'',
layout:'fit',
items: [
{
xtype: 'tabpanel',
activeTab: 0,
items: [
{
xtype: 'panel',
title: 'inf'
},
{
xtype: 'panel',
title: 'reg',
layout: 'form'?
items: [
{
xtype: 'textfield',
fieldLabel: 'Name',
vtype: 'name'
},
{
xtype: 'textfield',
fieldLabel: 'Login',
vtype: 'name'
},
{
xtype: 'textfield',
fieldLabel: 'Password',
vtype: 'pass'
},
{
xtype: 'textfield',
fieldLabel: 'Repeat password',
vtype: 'pass'
},
{
xtype: 'button',
text: 'SUBMIT',
onClick: form_data_eval()
}
]
}
]
}
],
Here is a function that requires an identifier, which I did not have:
function form_data_eval()
{
if (reg.isValid() == true)
{
reg.submit();
}
else
{
reg.markInvalid();
Ext.MessageBox.alert('Error!', 'Some text');
}
}
I have highlighted it in red. How do I get an ID in my case?
Thanks in advance.

Condor
17 Jan 2011, 6:42 AM
You need a formpanel in your window to be able to call submit().

If you do then you could use:

handler: form_data_eval // <- no ()!
...
function form_data_eval(){
// 'this' will be the button, so you can locate the parent form using:
var form = this.findParentByType('form').getForm();
form.submit(); // submit already does validation (unless you set clientValidation:false).
}

dvelopp
18 Jan 2011, 12:16 AM
Thanks! I will try.