PageRenderTime 50ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/webapp/lib/extjs/examples/grid/locking-infinite-scroll.js

https://bitbucket.org/glebiuskv/extjs-overlay
JavaScript | 116 lines | 105 code | 5 blank | 6 comment | 0 complexity | f37b15d603e352607020397310296037 MD5 | raw file
  1. Ext.Loader.setConfig({enabled: true});
  2. Ext.Loader.setPath('Ext.ux', '../ux/');
  3. Ext.require([
  4. 'Ext.grid.*',
  5. 'Ext.data.*',
  6. 'Ext.util.*',
  7. 'Ext.grid.plugin.BufferedRenderer'
  8. ]);
  9. Ext.onReady(function(){
  10. Ext.define('ForumThread', {
  11. extend: 'Ext.data.Model',
  12. fields: [
  13. 'title', 'forumtitle', 'forumid', 'username', {
  14. name: 'replycount',
  15. type: 'int'
  16. }, {
  17. name: 'lastpost',
  18. mapping: 'lastpost',
  19. type: 'date',
  20. dateFormat: 'timestamp'
  21. },
  22. 'lastposter', 'excerpt', 'threadid'
  23. ],
  24. idProperty: 'threadid'
  25. });
  26. // create the Data Store
  27. var store = Ext.create('Ext.data.Store', {
  28. id: 'store',
  29. model: 'ForumThread',
  30. remoteSort: true,
  31. // allow the grid to interact with the paging scroller by buffering
  32. buffered: true,
  33. pageSize: 100,
  34. proxy: {
  35. // load using script tags for cross domain, if the data in on the same domain as
  36. // this page, an HttpProxy would be better
  37. type: 'jsonp',
  38. url: 'http://www.sencha.com/forum/remote_topics/index.php',
  39. reader: {
  40. root: 'topics',
  41. totalProperty: 'totalCount'
  42. },
  43. // sends single sort as multi parameter
  44. simpleSortMode: true
  45. },
  46. sorters: [{
  47. property: 'lastpost',
  48. direction: 'DESC'
  49. }],
  50. autoLoad: true
  51. });
  52. function renderTopic(value, p, record) {
  53. return Ext.String.format(
  54. '<a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a>',
  55. value,
  56. record.data.forumtitle,
  57. record.getId(),
  58. record.data.forumid
  59. );
  60. }
  61. var grid = Ext.create('Ext.grid.Panel', {
  62. width: 700,
  63. height: 500,
  64. collapsible: true,
  65. title: 'ExtJS.com - Browse Forums',
  66. store: store,
  67. loadMask: true,
  68. selModel: {
  69. pruneRemoved: false
  70. },
  71. multiSelect: true,
  72. viewConfig: {
  73. trackOver: false
  74. },
  75. // grid columns
  76. columns:[{
  77. xtype: 'rownumberer',
  78. width: 50,
  79. sortable: false,
  80. locked: true,
  81. lockable: false
  82. },{
  83. tdCls: 'x-grid-cell-topic',
  84. text: "Topic",
  85. dataIndex: 'title',
  86. flex: 1,
  87. renderer: renderTopic,
  88. sortable: false
  89. },{
  90. text: "Author",
  91. dataIndex: 'username',
  92. width: 100,
  93. hidden: true,
  94. sortable: true
  95. },{
  96. text: "Replies",
  97. dataIndex: 'replycount',
  98. align: 'center',
  99. width: 70,
  100. sortable: false
  101. },{
  102. id: 'last',
  103. text: "Last Post",
  104. dataIndex: 'lastpost',
  105. width: 130,
  106. renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
  107. sortable: true
  108. }],
  109. renderTo: Ext.getBody()
  110. });
  111. });