PDA

View Full Version : special form



lormitto
31 Jan 2010, 11:35 PM
Hi,

I would like to ask if there is any way to use form i following way:

Form has checkboxes. Checking any of them causes that more text fields appear to fill.
Could you please advise how to make this or where to look for tutorial.

Thank you in advance.

nicobarten
1 Feb 2010, 12:04 AM
So guess you have 5 checkboxes below each other, and when a checkbox is checked a textfield to the right of the checkbox appears. I don't think this is that difficult, just place the textfields in the form already, and make them all hidden as default.

After that, put some code in the check event of each checkbox, which makes the textfield of the checkbox visible or hidden.

lormitto
1 Feb 2010, 5:57 AM
If you could please look at the code below and suggest go to resolve that issue:


items: [{
xtype: 'checkbox',
checked: true,
fieldLabel: 'hereLabe',
name: 'hereName',
listeners: {
check: function(checkbox, checked) {
if (checkbox.skipConfirm) {
delete checkbox.skipConfirm;
return;
}
if (!checked) {
checkbox.setValue(true);
Ext.Msg.confirm('Confirm', 'question?', function(btn) {
if (btn == 'yes') {
checkbox.skipConfirm = true;
checkbox.setValue(false);
}
});
}
}
}
},
{
fieldLabel: 'someText',
name: 'test1',
allowBlank:false
},

I've got no idea how to connect checkbox with label below. I want this labale to appear after checking checkbox but how to do this?

nicobarten
1 Feb 2010, 9:58 AM
Well it's not a label, i guess it's a textfield. Just give it an id, like:



{
fieldLabel: 'someText',
id: 'myTextfield',
name: 'test1',
allowBlank:false
},



Now in the check event, when the checkbox is checked do:



Ext.getCmp('myTextfield').show();


And when the checkbox is unchecked do:



Ext.getCmp('myTextfield').hide();

lormitto
1 Feb 2010, 11:44 PM
Well it's not a label, i guess it's a textfield. Just give it an id, like:



{
fieldLabel: 'someText',
id: 'myTextfield',
name: 'test1',
allowBlank:false
},



Now in the check event, when the checkbox is checked do:



Ext.getCmp('myTextfield').show();
And when the checkbox is unchecked do:



Ext.getCmp('myTextfield').hide();



Thank you. This is it. But one more problem appeared. In this case textfield disappears but 'someText' on the left remains as label. I think that's the last thing I ask for :)

Kind Regards

nicobarten
2 Feb 2010, 12:38 AM
Try:



Ext.getCmp('myTextfield').hideLabel = true;

lormitto
2 Feb 2010, 12:44 AM
Try:



Ext.getCmp('myTextfield').hideLabel = true;


Unfortunately there is no variable hideLabel.
It does not work :(

nicobarten
2 Feb 2010, 3:57 AM
guess you need to try this:

http://www.extjs.com/forum/showthread.php?p=120152#post120152

although i didn't try it myself.

lormitto
2 Feb 2010, 4:23 AM
thank you very much

just simple line:


Ext.layout.FormLayout.prototype.trackLabels = true;

and it is ok now


where to learn all this to be very good extjs user? :)

nicobarten
2 Feb 2010, 5:04 AM
Well if you ask me, it's just learning all the way. In short, it's experience. The longer you'll work with Extjs, the more things you learn and discover.

I know the basics, but there's still much to learn. The real experts are people like Animal or Condor (and a lot more of course but i didn't remember them).

lormitto
2 Feb 2010, 5:05 AM
thank you again


i like extjs

i would like to learn it and perhaps later build commercial applications if that would be possible :)