You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.onReady(function(){
  16. var store = new Ext.data.Store({
  17. remoteSort: true,
  18. baseParams: {lightWeight:true,ext: 'js'},
  19. sortInfo: {field:'lastpost', direction:'DESC'},
  20. autoLoad: {params:{start:0, limit:500}},
  21. proxy: new Ext.data.ScriptTagProxy({
  22. url: 'http://extjs.com/forum/topics-browse-remote.php'
  23. }),
  24. reader: new Ext.data.JsonReader({
  25. root: 'topics',
  26. totalProperty: 'totalCount',
  27. idProperty: 'threadid',
  28. fields: [
  29. 'title', 'forumtitle', 'forumid', 'author',
  30. {name: 'replycount', type: 'int'},
  31. {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
  32. 'lastposter', 'excerpt'
  33. ]
  34. })
  35. });
  36. var grid = new Ext.grid.GridPanel({
  37. renderTo: 'topic-grid',
  38. width:700,
  39. height:500,
  40. frame:true,
  41. title:'ExtJS.com - Browse Forums',
  42. trackMouseOver:false,
  43. autoExpandColumn: 'topic',
  44. store: store,
  45. columns: [new Ext.grid.RowNumberer({width: 30}),{
  46. id: 'topic',
  47. header: "Topic",
  48. dataIndex: 'title',
  49. width: 420,
  50. renderer: renderTopic,
  51. sortable:true
  52. },{
  53. header: "Replies",
  54. dataIndex: 'replycount',
  55. width: 70,
  56. align: 'right',
  57. sortable:true
  58. },{
  59. id: 'last',
  60. header: "Last Post",
  61. dataIndex: 'lastpost',
  62. width: 150,
  63. renderer: renderLast,
  64. sortable:true
  65. }],
  66. bbar: new Ext.PagingToolbar({
  67. store: store,
  68. pageSize:500,
  69. displayInfo:true
  70. }),
  71. view: new Ext.ux.grid.BufferView({
  72. // custom row height
  73. rowHeight: 34,
  74. // render rows as they come into viewable area.
  75. scrollDelay: false
  76. })
  77. });
  78. // render functions
  79. function renderTopic(value, p, record){
  80. return String.format(
  81. '<b><a href="http://extjs.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://extjs.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>',
  82. value, record.data.forumtitle, record.id, record.data.forumid);
  83. }
  84. function renderLast(value, p, r){
  85. return String.format('{0}<br/>by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']);
  86. }
  87. });