-
24 May 2010 1:10 PM #1
How do I use the JSON Export
How do I use the JSON Export
I've been using the trial version of the Ext Designer and have found it very useful as a starting place; and I've learned a lot from it.
There is one thing, however, that is confusing me
When I go to Export, I can view it as Javscript, where a base class is extended with my layout, or there is a pure json version.
Is there any way I can use the json version to generate the layout?
For example, I'm looking at getting PHP to output the JSON that will define the layout. Event handlers will come a bit later
-
24 May 2010 1:22 PM #2Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
You can certainly use the JSON output. Simply click "Copy to Clipboard" and you can paste it into your IDE as either an items configuration of another Container, or pass directly to Ext.ComponentMgr.create. Knowledge of the Ext JS API is helpful, and you should read the docs. Below are both usages:
PreferredCode:var myPanel = new Ext.Panel({ renderTo: Ext.getBody(), items: [ // your JSON config ] });
Code:var myCmp = Ext.ComponentMgr.create(/* your JSON config */);
-
24 May 2010 1:51 PM #3
Many Thanks,
That makes a lot of sense - I'll try it when I'm back in the office tomorrow
-
24 May 2010 1:58 PM #4Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
You're quite welcome. I will say though that, generally speaking, it's recommended (in large & complex projects) to instead create & use sub-classes that package up your configuration and behavior. You can define your own xtype's using Ext.reg() and can create a loadable JSON config from your PHP code that is a configuration of your custom xtype'ed sub-classes, rather than a verbose configuration of the Ext JS components. The biggest advantage besides good practice and reuseability/extensibility, is that your behavior & event handlers can be packaged inside of your sub-classes...which is not the case using straight JSON.
-
25 May 2010 3:28 PM #5
More Information
More Information
Hi,
We are looking to do a similar thing to this from our Java Web app. Is there any more documentation or examples on doing this?
I've been looking for hours and this is all I managed to find. I would of expected the ExtJS docs to have provided a description (and examples) of using server created JSON to dynamically build forms.
Regards,
Carl
-
27 May 2010 10:47 AM #6
I tried your two Code examples combined with an ajax call:
While small examples like a form with two fields worked without problems, more complex examples didnt work. Is there a limitation how big a JSON structure can be? It always stops after "Ext.ComponentMgr.create".Code:success: function(response, opts) { var decodedResponse = Ext.decode(response.responseText); var myCmp = Ext.ComponentMgr.create(decodedResponse); this.window.add(myCmp); this.window.doLayout(); }
-
27 May 2010 11:14 AM #7Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
Can you send an example of your JSON output? I'd be able to tell you what went wrong...
-
27 May 2010 1:09 PM #8
Thank you for your answer, I just found it myself (at home while taking a shower):
The ajax call and the JSON output were correct. In my JSON file is a grid and some comboboxes and i just forgot to set up the datastores first. Next time i'll go home and take a shower earlier.. saves hours of debugging ;-)
Now I can do "lazy loading" of entire forms in my Ext.window-based application. So it can grow without caring about long initial loading times.
Michael
-
27 May 2010 7:10 PM #9Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
Sounds most excellent...that's the beauty of xtypes :-) Good deal.
Similar Threads
-
[CLOSED-126] Export Code to Disk not honoring export path in preferences
By tr888 in forum Ext Designer: BugsReplies: 3Last Post: 10 May 2010, 9:10 AM -
Export Store Data to json
By mgoncharov in forum Ext 3.x: Help & DiscussionReplies: 5Last Post: 28 Nov 2009, 6:55 PM -
Export data as json
By oe800r in forum Ext 2.x: Help & DiscussionReplies: 8Last Post: 20 Jun 2008, 7:51 AM -
How to export data from JSON?
By Effadreen in forum Ext 1.x: Help & DiscussionReplies: 7Last Post: 19 May 2007, 9:47 AM


Reply With Quote