--- /dev/null
+<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">ListLoader = function(config){\r
+ Ext.apply(this, config);\r
+};\r
+\r
+Ext.extend(ListLoader, Ext.util.Observable, {\r
+ keyAttribute: 'id',\r
+ keyField: 'parentId',\r
+ \r
+ load: function(node, callback){\r
+ var key = this.keyField;\r
+ var v = node.attributes[this.keyAttribute];\r
+ var rs = this.store.queryBy(function(r){\r
+ return r.data[key] === v;\r
+ });\r
+ node.beginUpdate();\r
+ for (var i = 0, d = rs.items, len = d.length; i < len; i++) {\r
+ var n = this.createNode(d[i]);\r
+ if (n) {\r
+ node.appendChild(n);\r
+ }\r
+ }\r
+ node.endUpdate();\r
+ if(typeof callback == "function"){\r
+ callback(this, node);\r
+ }\r
+ },\r
+ \r
+ createNode : function(record){\r
+ var d = record.data, n;\r
+ if(d.isFolder){\r
+ n = new Ext.tree.AsyncTreeNode({\r
+ loader: this,\r
+ id: record.id,\r
+ text: d.listName,\r
+ leaf: false,\r
+ iconCls: 'icon-folder',\r
+ editable: true,\r
+ expanded: true,\r
+ isFolder: true\r
+ });\r
+ }else{\r
+ n = new Ext.tree.TreeNode({\r
+ id: record.id,\r
+ text: d.listName,\r
+ leaf: true,\r
+ iconCls: 'icon-list',\r
+ editable: true\r
+ });\r
+ }\r
+ return n;\r
+ }\r
+});</pre> \r
+</body>\r
+</html>
\ No newline at end of file