Dynamically add form elements in Extjs 4

Code snippet to dynamically add form elements in Extjs 4 with ease.


Ext.onReady(function() {

    var myForm = Ext.create('Ext.form.Panel', {
        title: 'Query form',
        width: 600,
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'button',
            text: 'click me to add',
            handler: function() {
                var tf = Ext.create('Ext.form.field.Text', {
                    name: 'name',
                    fieldLabel: 'Name'
                });
                myForm.add(tf);
            }
        }]
    });

});


Comments

  1. I love seeing stuff like this, want to contribute some learning materials to the framework itself? (ed @ sencha com if you're interested)

    ReplyDelete

Post a Comment

Popular posts from this blog

Getting Started: Quick Setup for GXT 3 (includes reset.css link how to)

How to setup GXT 3 examples, samples and demos

ExtJs4 : Dynamically Add Columns