Panel.js 2.4 KB

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