3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
15 Ext.Loader.setConfig({enabled: true});
17 Ext.Loader.setPath('Ext.ux', '../ux/');
23 'Ext.ux.PreviewPlugin',
25 'Ext.tip.QuickTipManager'
30 Ext.onReady(function(){
31 Ext.tip.QuickTipManager.init();
33 Ext.define('ForumThread', {
34 extend: 'Ext.data.Model',
36 'title', 'forumtitle', 'forumid', 'username',
37 {name: 'replycount', type: 'int'},
38 {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
39 'lastposter', 'excerpt', 'threadid'
41 idProperty: 'threadid'
44 // create the Data Store
45 var store = Ext.create('Ext.data.Store', {
50 // load using script tags for cross domain, if the data in on the same domain as
51 // this page, an HttpProxy would be better
53 url: 'http://www.sencha.com/forum/topics-browse-remote.php',
56 totalProperty: 'totalCount'
58 // sends single sort as multi parameter
68 function renderTopic(value, p, record) {
69 return Ext.String.format(
70 '<b><a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://sencha.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>',
72 record.data.forumtitle,
78 function renderLast(value, p, r) {
79 return Ext.String.format('{0}<br/>by {1}', Ext.Date.dateFormat(value, 'M j, Y, g:i a'), r.get('lastposter'));
83 var pluginExpanded = true;
84 var grid = Ext.create('Ext.grid.Panel', {
87 title: 'ExtJS.com - Browse Forums',
89 disableSelection: true,
104 // id assigned so we can apply custom css (e.g. .x-grid-cell-topic b { color:#333 })
105 // TODO: This poses an issue in subclasses of Grid now because Headers are now Components
106 // therefore the id will be registered in the ComponentManager and conflict. Need a way to
107 // add additional CSS classes to the rendered cells.
112 renderer: renderTopic,
116 dataIndex: 'username',
122 dataIndex: 'replycount',
129 dataIndex: 'lastpost',
131 renderer: renderLast,
134 // paging bar on the bottom
135 bbar: Ext.create('Ext.PagingToolbar', {
138 displayMsg: 'Displaying topics {0} - {1} of {2}',
139 emptyMsg: "No topics to display",
142 text: 'Show Preview',
143 pressed: pluginExpanded,
145 toggleHandler: function(btn, pressed) {
146 var preview = Ext.getCmp('gv').getPlugin('preview');
147 preview.toggleExpanded(pressed);
151 renderTo: 'topic-grid'
154 // trigger the data store load