1 | /* |
---|
2 | * Ext JS Library 0.30 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | // Implementation class for created the tree powered form field |
---|
10 | ListSelector = Ext.extend(Ext.ux.TreeSelector, { |
---|
11 | maxHeight:200, |
---|
12 | listenForLoad: false, |
---|
13 | initComponent : function(){ |
---|
14 | |
---|
15 | this.tree = new Ext.tree.TreePanel({ |
---|
16 | animate:false, |
---|
17 | border:false, |
---|
18 | width: this.treeWidth || 180, |
---|
19 | autoScroll:true, |
---|
20 | useArrows:true, |
---|
21 | selModel: new Ext.tree.ActivationModel(), |
---|
22 | loader : new ListLoader({store: this.store}) |
---|
23 | }); |
---|
24 | |
---|
25 | var root = new Ext.tree.AsyncTreeNode({ |
---|
26 | text: 'All Lists', |
---|
27 | id: 'root', |
---|
28 | leaf: false, |
---|
29 | iconCls: 'icon-folder', |
---|
30 | expanded: true, |
---|
31 | isFolder: true |
---|
32 | }); |
---|
33 | this.tree.setRootNode(root); |
---|
34 | |
---|
35 | this.tree.on('render', function(){ |
---|
36 | this.store.bindTree(this.tree); |
---|
37 | }, this); |
---|
38 | |
---|
39 | ListSelector.superclass.initComponent.call(this); |
---|
40 | |
---|
41 | // selecting folders is not allowed, so filter them |
---|
42 | this.tree.getSelectionModel().on('beforeselect', this.beforeSelection, this); |
---|
43 | |
---|
44 | // if being rendered before the store is loaded, reload when it is loaded |
---|
45 | if(this.listenForLoad) { |
---|
46 | this.store.on('load', function(){ |
---|
47 | root.reload(); |
---|
48 | }, this, { |
---|
49 | single: true |
---|
50 | }); |
---|
51 | } |
---|
52 | }, |
---|
53 | |
---|
54 | beforeSelection : function(tree, node){ |
---|
55 | if(node && node.attributes.isFolder){ |
---|
56 | node.toggle(); |
---|
57 | return false; |
---|
58 | } |
---|
59 | } |
---|
60 | }); |
---|