Daily Archives: November 15, 2012

Reading and Applying Dynamic Layout Configs in Ext JS / Sencha Touch

app.js

Ext.application({
  name : 'Demo',
  launch : function() {
    Ext.Ajax.request({
     url : 'layout.json',
     success : function(response) {
       var text = response.responseText;
       // process server response here
       var myLayout = Ext.decode(text);

       // apply the config
       Ext.create("Ext.Container", {
         renderTo: Ext.getBody(),
         layout: 'hbox',
         items: myLayout
       })
     }
  });
 }
});

layout.json

[
  {xtype: 'component', html: 'Hello World'},
  {xtype: 'component', html: 'Hello World 2'}
]