Results 1 to 3 of 3

Thread: Get items property after component been created

  1. #1
    Sencha User
    Join Date
    Oct 2010
    Location
    Brazil - MG, Belo Horizonte
    Posts
    62
    Answers
    4

    Question Get items property after component been created

    Well guys, i'm building form generator which i need to insert dynamic components to a panel, component as textfield, textareas, an etc. My question is:

    Code:
    There is a way to retrieve item property?
    Example: When we create a new panel, we use this markup... 
    Ext.create('Ext.panel.Panel', {
        title: 'Simple panel',
        height: 300,
        width: 300,
        items:[{
        // Here we put other components, and my forms will be added here
        }]
    })
    There's a way to get the items property that i had setted on creation? (and updated it on the fly)

  2. #2
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106

    Default

    Ext.ComponentQuery.query('<some CSS-like selector here>') is the way to go. You should consider at least providing your panel with an itemId attribute, like so:

    Code:
    Ext.create('Ext.panel.Panel', {
        title: 'Simple panel',
        itemId: 'targetPanel',
        height: 300,
        width: 300,
        items:[{
           // Here we put other components, and my forms will be added here
        }]
    })
    You could then do things like this:

    Code:
    var targetComponent = Ext.ComponentQuery.query('#targetPanel')[0].down('textarea');

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    The items config option get converted into a MixedCollection containing the child components. This only happens at instantiation time. If you need to add child components later you have to use a suitable method on the container instead:

    http://docs.sencha.com/ext-js/4-0/#!...ner-method-add
    http://docs.sencha.com/ext-js/4-0/#!...-method-insert

    Code:
    var panel = Ext.create('Ext.panel.Panel', {
        title: 'Simple panel',
        height: 300,
        width: 300,
        items:[
            ...
        ]
    });
    
    panel.add({
        xtype: 'textfield',
        ...
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •