Angel’s Blog

Someone right now is looking pretty tired, staring at a laptop trying to get inspired…

Generating Items in ExtJS with JSON (php/mysql)


After some time having a really hardcore sex whit the ExtJS framework (i was on the passive side) i found the solutions of the question about the life, the universe and everything else and it isn’t 42!

Here is the source :

  1.  
  2. Ext.Ajax.request({
  3. url : 'http://localhost/oc/api.php',
  4. params : {
  5. a : 'tabs'
  6. },
  7.  
  8. method : 'GET',
  9. // This is the output of api.php
  10. // {"data":[{"title":"tab 1","id":"0"},{"title":"tab 2","id":"1"}]}
  11.  
  12. success : function(result, request) {
  13. jsonData = Ext.util.JSON.decode(result.responseText);
  14.  
  15. // here we are generating an array with JSON objects
  16.  
  17. var personalPanel = new Ext.form.FormPanel({
  18.  
  19. title : 'Personal',
  20.  
  21. defaultType : 'tabpanel',
  22. defaults : {
  23.  
  24. msgTarget : 'side'
  25. },
  26. layoutConfig : {
  27.  
  28. },
  29. items : [{
  30. xtype : "tabpanel",
  31. items : jsonData.data
  32. // Here we are using the jsonData.data (.data because my json formated output has a root key "data:…"

No need to write the the end of the script, this was the most important part of it.





Comments



1
Author:  Bob C | Date:  July 29, 2010 | Time:  10:15 pm

Just what I was looking for
Thanks for letting ExtJS have sex with you:)



Write a Comment

Note: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>