Panel.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * @Description:
  3. * @Author: hy
  4. * @Date: 2019-08-15 09:28:19
  5. * @LastEditTime: 2019-08-16 17:13:37
  6. */
  7. /**
  8. * This example shows how to use the grouping feature of the Grid.
  9. */
  10. Ext.define('uas.view.grid.grouped.Panel', {
  11. extend: 'Ext.grid.Panel',
  12. xtype: 'grouped-grid',
  13. controller: 'grouped-grid',
  14. bind: '{restaurants}',
  15. columns: [{
  16. text: 'Name',
  17. dataIndex: 'name',
  18. summaryType: 'count',
  19. summaryRenderer: function(value, summaryData, dataIndex) {
  20. return Ext.String.format('共有{0}条数据', value);
  21. },
  22. flex: 1
  23. }, {
  24. text: 'Cuisine',
  25. dataIndex: 'cuisine',
  26. flex: 1
  27. }, {
  28. text: 'Rating',
  29. dataIndex: 'rating',
  30. flex: 1
  31. }],
  32. features: [{
  33. ftype: 'grouping',
  34. startCollapsed: true,
  35. groupHeaderTpl: '{columnName}: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
  36. }, {
  37. ftype: 'summary',
  38. fixed: true
  39. }],
  40. viewModel: {
  41. data: {
  42. groupBy: null
  43. },
  44. stores: {
  45. restaurants: {
  46. type: 'restaurants',
  47. autoLoad: false,
  48. listeners: {
  49. groupchange: 'onGroupChange',
  50. buffer: 100
  51. }
  52. }
  53. }
  54. },
  55. viewConfig: {
  56. listeners: {
  57. groupcollapse: 'onGroupCollapse',
  58. groupexpand: 'onGroupExpand'
  59. }
  60. },
  61. tbar: ['->', {
  62. xtype: 'tool',
  63. type: 'plus',
  64. handler: 'onExpandAll',
  65. tooltip: 'Expand all groups',
  66. bind: {
  67. hidden: '{!groupBy}'
  68. }
  69. }, {
  70. xtype: 'tool',
  71. type: 'minus',
  72. handler: 'onCollapseAll',
  73. tooltip: 'Collapse all groups',
  74. bind: {
  75. hidden: '{!groupBy}'
  76. }
  77. // }, {
  78. // text: 'Toggle groups...',
  79. // reference: 'groupsBtn',
  80. // bind: {
  81. // disabled: '{!groupBy}'
  82. // },
  83. // destroyMenu: true,
  84. // menu: {
  85. // hideOnScroll: false,
  86. // items: []
  87. // }
  88. }],
  89. fbar: [{
  90. text: 'Disable Grouping',
  91. handler: 'onDisableGroupingClick',
  92. bind: {
  93. hidden: '{!groupBy}'
  94. }
  95. }, {
  96. text: 'Enable Grouping',
  97. handler: 'onEnableGroupingClick',
  98. bind: {
  99. hidden: '{groupBy}'
  100. }
  101. }]
  102. });