X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/examples/forum/classes/ForumList.js diff --git a/examples/forum/classes/ForumList.js b/examples/forum/classes/ForumList.js new file mode 100644 index 00000000..789f6ddb --- /dev/null +++ b/examples/forum/classes/ForumList.js @@ -0,0 +1,59 @@ +Ext.define('ForumBrowser.ForumList', { + + extend: 'Ext.tree.Panel', + + alias: 'widget.forumlist', + + rootVisible: false, + lines: false, + defaultForum: 40, + + minWidth: 200, + + initComponent: function(){ + Ext.apply(this, { + viewConfig: { + getRowClass: function(record) { + if (!record.get('leaf')) { + return 'forum-parent'; + } + } + }, + store: Ext.create('Ext.data.TreeStore', { + model: 'ForumBrowser.Forum', + root: { + expanded: true + }, + proxy: { + type: 'jsonp', + url: 'http://sencha.com/forum/forums-remote.php', + reader: { + type: 'json', + root: 'children' + } + }, + listeners: { + single: true, + scope: this, + load: this.onFirstLoad + } + }) + }); + this.callParent(); + this.getSelectionModel().on({ + scope: this, + select: this.onSelect + }); + }, + + onFirstLoad: function(){ + var rec = this.store.getNodeById(this.defaultForum); + this.getSelectionModel().select(rec); + }, + + onSelect: function(selModel, rec){ + if (rec.get('leaf')) { + this.ownerCt.loadForum(rec); + } + } +});