check-tree.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Ext.require([
  2. 'Ext.tree.*',
  3. 'Ext.data.*',
  4. 'Ext.window.MessageBox'
  5. ]);
  6. Ext.onReady(function() {
  7. var store = Ext.create('Ext.data.TreeStore', {
  8. proxy: {
  9. type: 'ajax',
  10. url: 'check-nodes.json'
  11. },
  12. sorters: [{
  13. property: 'leaf',
  14. direction: 'ASC'
  15. }, {
  16. property: 'text',
  17. direction: 'ASC'
  18. }]
  19. });
  20. var tree = Ext.create('Ext.tree.Panel', {
  21. store: store,
  22. rootVisible: false,
  23. useArrows: true,
  24. frame: true,
  25. title: 'Check Tree',
  26. renderTo: 'tree-div',
  27. width: 200,
  28. height: 250,
  29. dockedItems: [{
  30. xtype: 'toolbar',
  31. items: {
  32. text: 'Get checked nodes',
  33. handler: function(){
  34. var records = tree.getView().getChecked(),
  35. names = [];
  36. Ext.Array.each(records, function(rec){
  37. names.push(rec.get('text'));
  38. });
  39. Ext.MessageBox.show({
  40. title: 'Selected Nodes',
  41. msg: names.join('<br />'),
  42. icon: Ext.MessageBox.INFO
  43. });
  44. }
  45. }
  46. }]
  47. });
  48. });