PDA

View Full Version : How to show fields on form panel



newusername
9 Nov 2012, 1:41 AM
HI ,

If I have a form panel which contains say employee name , last name and salary and tax based on that salary.
Initially I will show all elements except tax .
When users fill up all the details and after saving , at server end I will calculate tax and will come back on same form showing all fields as readable along with tax field.

I mean
1. initially DOM should not contain tax field but later on it should... How can I do that ?
2. How can I show those fields as readable only ..

willigogs
9 Nov 2012, 2:00 AM
1. initially DOM should not contain tax field but later on it should... How can I do that ?
The easiest method would be to always include the field in the form, but hide it as default (hidden:true). Once you have completed the AJAX call, show the field and populate it with your received value.
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.TextField-cfg-hidden


2. How can I show those fields as readable only ..
Simply set the field as readOnly: true:
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.TextField-cfg-readOnly
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.TextField-method-setReadOnly (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.TextField-cfg-readOnly)

I would also recommend purchasing a decent book on EXTJS which should be able to teach you all the basics like this in a few hours. I heartily suggest the "ExtJS In Action" book by Jay Garcia :)

newusername
9 Nov 2012, 2:44 AM
Thanks for ur reply


The easiest method would be to always include the field in the form, but hide it as default (hidden:true).

but till if I do not wish that item to be in DOM .. what shall I do ?

Surely I will go through that book .

willigogs
9 Nov 2012, 3:40 AM
but till if I do not wish that item to be in DOM .. what shall I do ?
Use either the add() or insert() methods:
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.FieldSet-method-add
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.FieldSet-method-insert