PDA

View Full Version : problem with window...



petcy
5 Oct 2010, 1:31 AM
hiiiiiiiii


i want to get the values of text fields of a window???

win= new Ext.Window({

title: 'Pin Code Details..:'+pinno,
pageX: 100,
pageY: 100,
width: 300,
height: 200,
bodyStyle : 'padding: 5px',
layout : 'form',
labelWidth : 50,
defaultType : 'field',
items:[
{ xtype: 'combo', fieldLabel: 'State:',store:statelst,name:'winstate'},
{ xtype: 'textfield', fieldLabel: 'City:',name:'wincity'},
{ xtype: 'textfield', fieldLabel: 'Tel.Area Code:',name:'winacode'},
],

buttons: [{
text: 'Cancel',
handler: function() { win.hide(); }
},
{
text:'Save',
handler:dopinsave
}

]

}).show();



in the function how should i get the values of state,city and code

Jaitsu
5 Oct 2010, 2:43 AM
Have a read of the documentation here:
http://dev.sencha.com/deploy/dev/docs/

and have a look at the getCmp method in the Ext class, build from there and you're away

petcy
5 Oct 2010, 2:58 AM
in the case of a tab panel we will get it by the code below:

var form1 =Loginform.getForm();

var fname=form1.findField('firastname').getValue();....

...
if then what in the case of window??? to access window from outside

Jaitsu
5 Oct 2010, 3:14 AM
why bother getting the form and then iterating through every field in order to find the value? That's twice the work
in my opinion if you want to directly access a field's value you should be using Ext.getCmp() or Ext.fly, have a look at those methods in the docs and you'll see what i mean

petcy
5 Oct 2010, 3:26 AM
thanks.....but..

i went through the examples related to it...

like this...
var ww=Ext.getCmp("my_win").getForm();
var wstatel=ww.findField('winstate').getValue();

..
but these all are releted with form panel

In my case there is a window....generated from another event..

i wanna all the values to be saved from that window???


can u pls drop a bit of code/////

steffenk
5 Oct 2010, 3:41 AM
you miss one important!
layout: 'form' doesn't draw a form. You have to use a FormPanel as child to achieve this.
Explore the dom and you see the missing form tag. So getForm() never will work.

petcy
5 Oct 2010, 3:57 AM
hii mr.steffan...


is ther any other way to get the value of textField from a window directly...to a function

Jaitsu
5 Oct 2010, 3:58 AM
win= new Ext.Window({

title: 'Pin Code Details..:'+pinno,
pageX: 100,
pageY: 100,
width: 300,
height: 200,
bodyStyle : 'padding: 5px',
layout : 'form',
labelWidth : 50,
defaultType : 'field',
items:[
{ xtype: 'combo', fieldLabel: 'State:',store:statelst,name:'winstate'},
{ xtype: 'textfield', fieldLabel: 'City:',name:'wincity', id: 'field1' },
{ xtype: 'textfield', fieldLabel: 'Tel.Area Code:',name:'winacode'},
],

buttons: [{
text: 'Cancel',
handler: function() { win.hide(); }
},
{
text:'Save',
handler:dopinsave
}

]

}).show();

Then this will return the value of 'field1'...



Ext.getCmp('field1').getValue();

Condor
5 Oct 2010, 4:01 AM
You would have to get the values from each Field separately (which is something a FormPanel would help you with).

What is wrong with using a form, e.g.

win = new Ext.Window({
title: 'Pin Code Details..:' + pinno,
pageX: 100,
pageY: 100,
width: 300,
height: 200,
bodyStyle: 'padding: 5px',
layout: 'fit',
items: {
xtype: 'form',
border: false,
labelWidth: 50,
items: [{
xtype: 'combo',
fieldLabel: 'State:',
store: statelst,
name: 'winstate'
},
{
xtype: 'textfield',
fieldLabel: 'City:',
name: 'wincity'
},
{
xtype: 'textfield',
fieldLabel: 'Tel.Area Code:',
name: 'winacode'
}]
},
buttons: [{
text: 'Cancel',
handler: function () {
win.hide();
}
},
{
text: 'Save',
handler: function () {
var values = win.getComponent(0).getForm().getValues();
alert(Ext.encode(values));
}
}]
}).show();

petcy
5 Oct 2010, 4:04 AM
thank u soooo much Jaitsu...


Thats what i want...