2
votes

Is there a possibility in ExtJS library to create layuots based on some string representation?

Consider I have a server call which fills a response with the following data - "Ext.create('Ext.Button', {xtype: 'button', text: 'button form server'});" which is actually a valid javascript code to create a button ( being typed in source code editor it creates a button ).

Is there a way to get such a string response and to construct extjs's button based exactly on that string ?

For example: ajax's response.responseText equals to Ext.create('Ext.Button', {xtype: 'button', text: 'button form server'});. And what I demand is a component like Ext.someMagicStuff(response.responseText) which understands my passed string and creates a button.

Thank you very much for your time and any ideas !

1

1 Answers

3
votes

This is not that complicated for defined types. Just return a valid config like

{xtype: 'button', text: 'button form server'}

as JSON and resolve the answer using

Ext.ComponentManager.create(Ext.decode(response.responseText));

The componentmanager will automatically lookup the xtype and return the created instance