Panel.js 2.3 KB

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