3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">
\r
9 tx.data.ListStore = Ext.extend(Ext.data.Store, {
\r
10 constructor: function(){
\r
11 tx.data.ListStore.superclass.constructor.call(this, {
\r
12 sortInfo:{field: 'listName', direction: "ASC"},
\r
13 reader: new Ext.data.JsonReader({
\r
15 fields: tx.data.List
\r
18 this.boundTrees = {};
\r
19 this.conn = tx.data.conn;
\r
20 this.proxy = new Ext.sql.Proxy(tx.data.conn, 'list', 'listId', this);
\r
23 getName : function(id){
\r
24 var l = this.data.map[id];
\r
25 return l ? l.data.listName : '';
\r
28 addList : function(name, id, isFolder, parentId){
\r
29 var l = this.findList(name);
\r
31 var id = id || Ext.uniqueId();
\r
32 l = new tx.data.List({listId: id, listName: name, isFolder: isFolder === true, parentId: parentId || 'root'}, id);
\r
38 newList : function(isFolder, parentId){
\r
40 var text = isFolder ? 'New Folder ' : 'New List ';
\r
41 while(this.findList(text + i)){
\r
44 return this.addList(text + i, undefined, isFolder, parentId);
\r
47 findList : function(name){
\r
49 for(var i = 0, len = d.length; i < len; i++){
\r
50 if(d.items[i].data.listName === name){
\r
57 loadDemoLists: function(){
\r
58 this.addList('Personal', 'personal', true, 'root');
\r
59 this.addList('Family', 'family', false, 'personal');
\r
60 this.addList('Bills', 'bills', false, 'personal');
\r
61 this.addList('Fun', 'fun', false, 'personal');
\r
62 this.addList('Other Stuff', 'personal-misc', false, 'personal');
\r
63 this.addList('Work', 'work', true, 'root');
\r
64 this.addList('Ext 2.x', 'ext2', false, 'work');
\r
65 this.addList('Ext 1.x', 'ext1', false, 'work');
\r
66 this.addList('Meetings', 'meetings', false, 'work');
\r
67 this.addList('Miscellaneous', 'work-misc', false, 'work');
\r
70 bindTree : function(tree){
\r
71 this.boundTrees[tree.id] = {
\r
72 add: function(ls, records){
\r
73 var pnode = tree.getNodeById(records[0].data.parentId);
\r
79 remove: function(ls, record){
\r
80 var node = tree.getNodeById(record.id);
\r
81 if(node && node.parentNode){
\r
82 node.parentNode.removeChild(node);
\r
86 update: function(ls, record){
\r
87 var node = tree.getNodeById(record.id);
\r
89 node.setText(record.data.listName);
\r
94 this.on(this.boundTrees[tree.id]);
\r
97 unbindTree : function(tree){
\r
98 var h = this.boundTrees[tree.id];
\r
100 this.un('add', h.add);
\r
101 this.un('remove', h.remove);
\r
102 this.un('update', h.update);
\r
106 prepareTable : function(){
\r
111 fields: tx.data.List.prototype.fields
\r
113 }catch(e){console.log(e);}
\r