app.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @example Grouping Grid Panel
  3. *
  4. * A grid panel that demonstrates grouping rows using the {@link Ext.grid.feature.Grouping} feature
  5. */
  6. Ext.require('Ext.data.Store');
  7. Ext.require('Ext.grid.Panel');
  8. Ext.define('Employee', {
  9. extend: 'Ext.data.Model',
  10. fields: [ 'name', 'seniority', 'department' ]
  11. });
  12. Ext.onReady(function() {
  13. var employeeStore = Ext.create('Ext.data.Store', {
  14. model: 'Employee',
  15. data: [
  16. { name: 'Michael Scott', seniority: 7, department: 'Management' },
  17. { name: 'Dwight Schrute', seniority: 2, department: 'Sales' },
  18. { name: 'Jim Halpert', seniority: 3, department: 'Sales' },
  19. { name: 'Kevin Malone', seniority: 4, department: 'Accounting' },
  20. { name: 'Angela Martin', seniority: 5, department: 'Accounting' }
  21. ],
  22. groupField: 'department'
  23. });
  24. Ext.create('Ext.grid.Panel', {
  25. renderTo: Ext.getBody(),
  26. store: employeeStore,
  27. width: 200,
  28. height: 300,
  29. title: 'Employees - Scranton Branch',
  30. columns: [
  31. {
  32. text: 'Name',
  33. width: 100,
  34. dataIndex: 'name'
  35. },
  36. {
  37. text: 'Seniority',
  38. flex: 1,
  39. dataIndex: 'seniority'
  40. }
  41. ],
  42. features: [{ ftype: 'grouping' }]
  43. });
  44. });