app.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @example Paging Toolbar
  3. *
  4. * This example demonstrates loading data in pages dynamically from the server using a {@link Ext.toolbar.Paging Paging Toolbar}.
  5. * Note, that since there is no back end (data is loaded from a static file at `data/users.json`) each page will show the same data set.
  6. */
  7. Ext.require('Ext.data.Store');
  8. Ext.require('Ext.grid.Panel');
  9. Ext.require('Ext.toolbar.Paging');
  10. Ext.define('User', {
  11. extend: 'Ext.data.Model',
  12. fields: [ 'name', 'email', 'phone' ]
  13. });
  14. Ext.onReady(function() {
  15. var userStore = Ext.create('Ext.data.Store', {
  16. model: 'User',
  17. autoLoad: true,
  18. pageSize: 4,
  19. proxy: {
  20. type: 'ajax',
  21. url : 'data/users.json',
  22. reader: {
  23. type: 'json',
  24. root: 'users',
  25. totalProperty: 'total'
  26. }
  27. }
  28. });
  29. Ext.create('Ext.grid.Panel', {
  30. renderTo: Ext.getBody(),
  31. store: userStore,
  32. width: 400,
  33. height: 200,
  34. title: 'Application Users',
  35. columns: [
  36. {
  37. text: 'Name',
  38. width: 100,
  39. dataIndex: 'name'
  40. },
  41. {
  42. text: 'Email Address',
  43. width: 150,
  44. dataIndex: 'email'
  45. },
  46. {
  47. text: 'Phone Number',
  48. flex: 1,
  49. dataIndex: 'phone'
  50. }
  51. ],
  52. dockedItems: [{
  53. xtype: 'pagingtoolbar',
  54. store: userStore, // same store GridPanel is using
  55. dock: 'bottom',
  56. displayInfo: true
  57. }]
  58. });
  59. });