PDA

View Full Version : Extjs4.1 Hidden field bug



zhangwonderful
4 May 2012, 2:49 PM
When I create a hidden field in the form, I can't get this component by invoking form.down('#itemId'). But it works before I immigrated to Extjs4.1.0 version.

vietits
4 May 2012, 5:14 PM
With me, it still works:


Ext.onReady(function(){
var form = Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 275,
height: 120,
items: [{
xtype: 'hidden',
itemId: 'HiddenField',
name: 'hidden_field'
}]
});
console.log(form.down('#HiddenField'))
});

zhangwonderful
6 May 2012, 1:28 PM
Are you sure that you create this form under ExtJS4.1.0 gpl version?
When I debug the program and check this form's items, there aren't any hidden field list in this collection. I can only find any fields that are unhidden. So when I get hidden field using form.down('#myHidden'), it always returns null object. But if I get unhidden object by invoking form.down('myUnhidden'), it returns the object I expected.
So I don't know how to solve this problem.

zhangwonderful
6 May 2012, 1:30 PM
Thank you vietits. I tried it again and again but I failed. If I run my program under ExtJS4.0, it works for me normally.


With me, it still works:


Ext.onReady(function(){
var form = Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 275,
height: 120,
items: [{
xtype: 'hidden',
itemId: 'HiddenField',
name: 'hidden_field'
}]
});
console.log(form.down('#HiddenField'))
});

vietits
6 May 2012, 3:26 PM
I am sure I ran this example on Ext 4.1.0-gpl, Chrome 18.

zhangwonderful
15 May 2012, 1:44 PM
If I code like this, it doesn't work.Ext.onReady(function(){ var form = Ext.create('Ext.form.Panel', { renderTo: Ext.getBody(), width: 275, height: 120, items: [[{ xtype: 'hidden', itemId: 'HiddenField2', name: 'hidden_field2' },{
xtype: 'hidden', itemId: 'HiddenField', name: 'hidden_field'}] }); console.log(form.down('#HiddenField'))});

Thank you vietits. I tried it again and again but I failed. If I run my program under ExtJS4.0, it works for me normally.

vietits
15 May 2012, 11:54 PM
It seems that it has an extra square bracket in your code and this will cause error:


Ext.onReady(function(){ var form = Ext.create('Ext.form.Panel', { renderTo: Ext.getBody(), width: 275, height: 120, items: [[{ xtype: 'hidden', itemId: 'HiddenField2', name: 'hidden_field2' },{
xtype: 'hidden', itemId: 'HiddenField', name: 'hidden_field'}] }); console.log(form.down('#HiddenField'))});

The following code works well on Chrome 18, Ext 4.1.0-gpl


Ext.onReady(function(){
var form = Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 275,
height: 120,
items: [{
xtype: 'hidden',
itemId: 'HiddenField2',
name: 'hidden_field2'
},{
xtype: 'hidden',
itemId: 'HiddenField',
name: 'hidden_field'
}]
});
console.log(form.down('#HiddenField'))
});