Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / forum / classes / ForumList.js
1 Ext.define('ForumBrowser.ForumList', {
2
3     extend: 'Ext.tree.Panel',
4     
5     alias: 'widget.forumlist',
6     
7     rootVisible: false,
8     lines: false,
9     defaultForum: 40,
10     
11     minWidth: 200,
12     
13     initComponent: function(){
14         Ext.apply(this, {
15             viewConfig: {
16                 getRowClass: function(record) {
17                     if (!record.get('leaf')) {
18                         return 'forum-parent';
19                     }
20                 }
21             },
22             store: Ext.create('Ext.data.TreeStore', {
23                 model: 'ForumBrowser.Forum',
24                 root: {
25                     expanded: true
26                 },
27                 proxy: {
28                     type: 'jsonp',
29                     url: 'http://sencha.com/forum/forums-remote.php',
30                     reader: {
31                         type: 'json',
32                         root: 'children'
33                     }
34                 },
35                 listeners: {
36                     single: true,
37                     scope: this,
38                     load: this.onFirstLoad
39                 }
40             })
41         });
42         this.callParent();
43         this.getSelectionModel().on({
44             scope: this,
45             select: this.onSelect
46         });
47     },
48     
49     onFirstLoad: function(){
50         var rec = this.store.getNodeById(this.defaultForum);
51         this.getSelectionModel().select(rec);
52     },
53     
54     onSelect: function(selModel, rec){
55         if (rec.get('leaf')) {
56             this.ownerCt.loadForum(rec);
57         }
58     }
59 });