Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / ListSelector.html
diff --git a/docs/source/ListSelector.html b/docs/source/ListSelector.html
new file mode 100644 (file)
index 0000000..bd11141
--- /dev/null
@@ -0,0 +1,61 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js">// Implementation class for created the tree powered form field\r
+ListSelector = Ext.extend(Ext.ux.TreeSelector, {\r
+       maxHeight:200,\r
+       listenForLoad: false,\r
+    initComponent : function(){\r
+               \r
+               this.tree = new Ext.tree.TreePanel({\r
+                       animate:false,\r
+                       border:false,\r
+                       width: this.treeWidth || 180,\r
+                       autoScroll:true,\r
+                       useArrows:true,\r
+                       selModel: new Ext.tree.ActivationModel(),\r
+                       loader : new ListLoader({store: this.store})            \r
+               });\r
+               \r
+               var root = new Ext.tree.AsyncTreeNode({\r
+               text: 'All Lists',\r
+                       id: 'root',\r
+                       leaf: false,\r
+                       iconCls: 'icon-folder',\r
+                       expanded: true,\r
+                       isFolder: true\r
+           });\r
+           this.tree.setRootNode(root);\r
+\r
+        this.tree.on('render', function(){\r
+            this.store.bindTree(this.tree);\r
+        }, this);\r
+               \r
+        ListSelector.superclass.initComponent.call(this);\r
+               \r
+               // selecting folders is not allowed, so filter them\r
+               this.tree.getSelectionModel().on('beforeselect', this.beforeSelection, this);\r
+               \r
+               // if being rendered before the store is loaded, reload when it is loaded\r
+               if(this.listenForLoad) {\r
+                       this.store.on('load', function(){\r
+                               root.reload();\r
+                       }, this, {\r
+                               single: true\r
+                       });\r
+               }\r
+    },\r
+       \r
+       beforeSelection : function(tree, node){\r
+               if(node && node.attributes.isFolder){\r
+                       node.toggle();\r
+                       return false;\r
+               }\r
+       }\r
+});</pre>    \r
+</body>\r
+</html>
\ No newline at end of file