reorder.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Ext.require([
  2. 'Ext.tree.*',
  3. 'Ext.data.*',
  4. 'Ext.tip.*'
  5. ]);
  6. Ext.onReady(function() {
  7. Ext.QuickTips.init();
  8. var store = Ext.create('Ext.data.TreeStore', {
  9. proxy: {
  10. type: 'ajax',
  11. url: 'get-nodes.php'
  12. },
  13. root: {
  14. text: 'Ext JS',
  15. id: 'src',
  16. expanded: true
  17. },
  18. folderSort: true,
  19. sorters: [{
  20. property: 'text',
  21. direction: 'ASC'
  22. }]
  23. });
  24. var tree = Ext.create('Ext.tree.Panel', {
  25. store: store,
  26. viewConfig: {
  27. plugins: {
  28. ptype: 'treeviewdragdrop'
  29. }
  30. },
  31. renderTo: 'tree-div',
  32. height: 300,
  33. width: 250,
  34. title: 'Files',
  35. useArrows: true,
  36. dockedItems: [{
  37. xtype: 'toolbar',
  38. items: [{
  39. text: 'Expand All',
  40. handler: function(){
  41. tree.getEl().mask('Expanding tree...');
  42. var toolbar = this.up('toolbar');
  43. toolbar.disable();
  44. tree.expandAll(function() {
  45. tree.getEl().unmask();
  46. toolbar.enable();
  47. });
  48. }
  49. }, {
  50. text: 'Collapse All',
  51. handler: function(){
  52. var toolbar = this.up('toolbar');
  53. toolbar.disable();
  54. tree.collapseAll(function() {
  55. toolbar.enable();
  56. });
  57. }
  58. }]
  59. }]
  60. });
  61. });