xml-tree.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Ext.require([
  2. 'Ext.tree.*',
  3. 'Ext.data.*'
  4. ]);
  5. Ext.onReady(function() {
  6. var store = Ext.create('Ext.data.TreeStore', {
  7. proxy: {
  8. type: 'ajax',
  9. url: 'get-nodes.php',
  10. extraParams: {
  11. isXml: true
  12. },
  13. reader: {
  14. type: 'xml',
  15. root: 'nodes',
  16. record: 'node'
  17. }
  18. },
  19. sorters: [{
  20. property: 'leaf',
  21. direction: 'ASC'
  22. },{
  23. property: 'text',
  24. direction: 'ASC'
  25. }],
  26. root: {
  27. text: 'Ext JS',
  28. id: 'src',
  29. expanded: true
  30. }
  31. });
  32. // create the Tree
  33. var tree = Ext.create('Ext.tree.Panel', {
  34. store: store,
  35. hideHeaders: true,
  36. rootVisible: true,
  37. viewConfig: {
  38. plugins: [{
  39. ptype: 'treeviewdragdrop'
  40. }]
  41. },
  42. height: 350,
  43. width: 400,
  44. title: 'Directory Listing',
  45. renderTo: 'tree-example',
  46. collapsible: true
  47. });
  48. });