PanelController.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Ext.define('uas.view.grid.grouped.PanelController', {
  2. extend: 'Ext.app.ViewController',
  3. alias: 'controller.grouped-grid',
  4. init: function (view) {
  5. this.groupingFeature = view.view.findFeature('grouping');
  6. },
  7. onDisableGroupingClick: function () {
  8. this.groupingFeature.disable();
  9. },
  10. onEnableGroupingClick: function() {
  11. this.groupingFeature.enable();
  12. },
  13. onCollapseAll: function () {
  14. this.groupingFeature.collapseAll();
  15. },
  16. onExpandAll: function () {
  17. this.groupingFeature.expandAll();
  18. },
  19. onGroupChange: function (store, grouper) {
  20. var me = this,
  21. // groupingFeature = me.groupingFeature,
  22. groupBy = grouper ? grouper.getProperty() : '',
  23. // groupsBtn = me.lookup('groupsBtn'),
  24. vm = me.getViewModel();
  25. // groups, items, menu,
  26. // len, i;
  27. // me.groupBy = groupBy;
  28. if (vm) {
  29. vm.set({
  30. groupBy: groupBy
  31. });
  32. }
  33. // if (groupBy) {
  34. // menu = groupsBtn.menu;
  35. // if (groupsBtn.groupBy !== groupBy) {
  36. // groupsBtn.groupBy = groupBy;
  37. // groups = store.getGroups();
  38. // items = [];
  39. // groups.each(function (group) {
  40. // items.push({
  41. // xtype: 'menucheckitem',
  42. // text: group.getGroupKey(),
  43. // handler: 'onToggleGroup'
  44. // });
  45. // });
  46. // menu.removeAll(true);
  47. // if (items.length) {
  48. // menu.add(items);
  49. // }
  50. // }
  51. // items = menu.items.items;
  52. // for (i = 0, len = items.length; i < len; ++i) {
  53. // items[i].setChecked(groupingFeature.isExpanded(items[i].text));
  54. // }
  55. // }
  56. },
  57. onToggleGroup: function (item) {
  58. this.groupingFeature[item.checked ? 'expand' : 'collapse'](item.text, {
  59. highlight: true
  60. });
  61. },
  62. onGroupCollapse: function (v, n, groupName) {
  63. this.syncGroup(groupName, false);
  64. },
  65. onGroupExpand: function (v, n, groupName) {
  66. this.syncGroup(groupName, true);
  67. },
  68. syncGroup: function (groupName, state) {
  69. // var groupsBtn = this.lookup('groupsBtn'),
  70. // items = groupsBtn.menu.items.items,
  71. // i;
  72. // for (i = items.length; i-- > 0; ) {
  73. // if (items[i].text === groupName) {
  74. // items[i].setChecked(state, true);
  75. // break;
  76. // }
  77. // }
  78. }
  79. });