1. #1
    Sencha User
    Join Date
    Jan 2011
    Posts
    8
    Vote Rating
    1
    zhangwonderful is on a distinguished road

      0  

    Default Answered: Extjs4.1 Hidden field bug

    Answered: Extjs4.1 Hidden field bug


    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.

  2. It seems that it has an extra square bracket in your code and this will cause error:
    Code:
    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
    Code:
    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'))
    });

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    With me, it still works:
    Code:
    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'))
    });

  4. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    8
    Vote Rating
    1
    zhangwonderful is on a distinguished road

      0  

    Default Thank you for your immediate help

    Thank you for your immediate help


    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.

  5. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    8
    Vote Rating
    1
    zhangwonderful is on a distinguished road

      0  

    Default


    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.

    Quote Originally Posted by vietits View Post
    With me, it still works:
    Code:
    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'))
    });

  6. #5
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    I am sure I ran this example on Ext 4.1.0-gpl, Chrome 18.

  7. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    8
    Vote Rating
    1
    zhangwonderful is on a distinguished road

      0  

    Default


    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'))});
    Quote Originally Posted by zhangwonderful View Post
    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.

  8. #7
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    It seems that it has an extra square bracket in your code and this will cause error:
    Code:
    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
    Code:
    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'))
    });

Thread Participants: 1

Tags for this Thread