3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 Ext.onReady(function(){
9 // create the Data Store
10 var store = new Ext.data.JsonStore({
12 totalProperty: 'totalCount',
13 idProperty: 'threadid',
17 'title', 'forumtitle', 'forumid', 'author',
18 {name: 'replycount', type: 'int'},
19 {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
20 'lastposter', 'excerpt'
23 // load using script tags for cross domain, if the data in on the same domain as
24 // this page, an HttpProxy would be better
25 proxy: new Ext.data.ScriptTagProxy({
26 url: 'http://extjs.com/forum/topics-browse-remote.php'
29 store.setDefaultSort('lastpost', 'desc');
33 function renderTopic(value, p, record){
35 '<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>',
36 value, record.data.forumtitle, record.id, record.data.forumid);
38 function renderLast(value, p, r){
39 return String.format('{0}<br/>by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']);
42 var grid = new Ext.grid.GridPanel({
45 title:'ExtJS.com - Browse Forums',
48 disableSelection:true,
53 id: 'topic', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
57 renderer: renderTopic,
67 dataIndex: 'replycount',
74 dataIndex: 'lastpost',
80 // customize view config
85 getRowClass : function(record, rowIndex, p, store){
87 p.body = '<p>'+record.data.excerpt+'</p>';
88 return 'x-grid3-row-expanded';
90 return 'x-grid3-row-collapsed';
94 // paging bar on the bottom
95 bbar: new Ext.PagingToolbar({
99 displayMsg: 'Displaying topics {0} - {1} of {2}',
100 emptyMsg: "No topics to display",
105 text: 'Show Preview',
106 cls: 'x-btn-text-icon details',
107 toggleHandler: function(btn, pressed){
108 var view = grid.getView();
109 view.showPreview = pressed;
117 grid.render('topic-grid');
119 // trigger the data store load
120 store.load({params:{start:0, limit:25}});