2 * Ext JS Library 0.30
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 tx.data.ListStore = Ext.extend(Ext.data.Store, {
\r
11 constructor: function(){
\r
12 tx.data.ListStore.superclass.constructor.call(this, {
\r
13 sortInfo:{field: 'listName', direction: "ASC"},
\r
14 reader: new Ext.data.JsonReader({
\r
16 fields: tx.data.List
\r
19 this.boundTrees = {};
\r
20 this.conn = tx.data.conn;
\r
21 this.proxy = new Ext.sql.Proxy(tx.data.conn, 'list', 'listId', this);
\r
24 getName : function(id){
\r
25 var l = this.data.map[id];
\r
26 return l ? l.data.listName : '';
\r
29 addList : function(name, id, isFolder, parentId){
\r
30 var l = this.findList(name);
\r
32 var id = id || Ext.uniqueId();
\r
33 l = new tx.data.List({listId: id, listName: name, isFolder: isFolder === true, parentId: parentId || 'root'}, id);
\r
39 newList : function(isFolder, parentId){
\r
41 var text = isFolder ? 'New Folder ' : 'New List ';
\r
42 while(this.findList(text + i)){
\r
45 return this.addList(text + i, undefined, isFolder, parentId);
\r
48 findList : function(name){
\r
50 for(var i = 0, len = d.length; i < len; i++){
\r
51 if(d.items[i].data.listName === name){
\r
58 loadDemoLists: function(){
\r
59 this.addList('Personal', 'personal', true, 'root');
\r
60 this.addList('Family', 'family', false, 'personal');
\r
61 this.addList('Bills', 'bills', false, 'personal');
\r
62 this.addList('Fun', 'fun', false, 'personal');
\r
63 this.addList('Other Stuff', 'personal-misc', false, 'personal');
\r
64 this.addList('Work', 'work', true, 'root');
\r
65 this.addList('Ext 2.x', 'ext2', false, 'work');
\r
66 this.addList('Ext 1.x', 'ext1', false, 'work');
\r
67 this.addList('Meetings', 'meetings', false, 'work');
\r
68 this.addList('Miscellaneous', 'work-misc', false, 'work');
\r
71 bindTree : function(tree){
\r
72 this.boundTrees[tree.id] = {
\r
73 add: function(ls, records){
\r
74 var pnode = tree.getNodeById(records[0].data.parentId);
\r
80 remove: function(ls, record){
\r
81 var node = tree.getNodeById(record.id);
\r
82 if(node && node.parentNode){
\r
83 node.parentNode.removeChild(node);
\r
87 update: function(ls, record){
\r
88 var node = tree.getNodeById(record.id);
\r
90 node.setText(record.data.listName);
\r
95 this.on(this.boundTrees[tree.id]);
\r
98 unbindTree : function(tree){
\r
99 var h = this.boundTrees[tree.id];
\r
101 this.un('add', h.add);
\r
102 this.un('remove', h.remove);
\r
103 this.un('update', h.update);
\r
107 prepareTable : function(){
\r
112 fields: tx.data.List.prototype.fields
\r
114 }catch(e){console.log(e);}
\r