PageRenderTime 29ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/source/Plug-in/ext/editable-column-tree.js

http://prosporous.googlecode.com/
JavaScript | 209 lines | 208 code | 1 blank | 0 comment | 20 complexity | 397838af9091c97d6ef8b6212a08e853 MD5 | raw file
  1Ext.onReady(function()
  2{
  3	var root = new Ext.tree.AsyncTreeNode({
  4            id:'0',
  5        	text:'?'});
  6    var store = new Ext.data.SimpleStore(
  7    {fields:['report'],
  8     data:[['Pasry'],['Pasents']]
  9    });
 10
 11    var combo_config =
 12    {
 13        id: 'chart_combo_list',
 14        store: store,
 15        displayField: 'report',
 16        xtype: 'combo',
 17        mode: 'local',
 18        triggerAction: 'all',
 19        width: 100,
 20        emptyText: 'Please select report type..',
 21        selectOnFocus: true
 22    };
 23    var tree = new Ext.tree.ColumnTree(
 24    {
 25        id: 'tree',
 26        region:'center',
 27        rootVisible: false,
 28        autoScroll: true,
 29        expandable: false,
 30        enableDD: true,
 31        title:false,
 32        tbar:
 33        [
 34            {
 35                text: '??',
 36                tooltip: '??',
 37                listeners:
 38                {
 39                    'click': function()
 40                    {
 41                        var json = tree.toJsonString(null, function(key, val)
 42                        {
 43                            return (key == 'leaf' || key == 'id' || key == 'task' || key == 'user');
 44                        },
 45                        {
 46                            menu_item: 'task',
 47                            menu_url: 'user'
 48                        });
 49                        alert(json);
 50                    },
 51                    scope: this
 52                }
 53            },'-',
 54            {
 55                text: '?????',
 56                tooltip: '?????',
 57                listeners:
 58                {
 59                    'click': function()
 60                    {
 61                        var selectedItem = tree.getSelectionModel().getSelectedNode();
 62                        if (! selectedItem)
 63                        {
 64                            selectedItem = tree.getRootNode();
 65                        }
 66                        handleCreate = function (btn, text, cBoxes)
 67                        {
 68                            if (btn == 'ok' && text)
 69                            {
 70                                var newNode = new Ext.tree.TreeNode(
 71                                {
 72                                    menu_item: text,
 73                                    menu_url: '',
 74                                    leaf: false,
 75                                    expandable: true,
 76                                    uiProvider: Ext.tree.ColumnNodeUI
 77                                });
 78                                if (selectedItem.isLeaf())
 79                                {
 80                                    selectedItem.parentNode.insertBefore(newNode, selectedItem.nextSibling);
 81                                }
 82                                else
 83                                {
 84                                    selectedItem.insertBefore(newNode, selectedItem.firstChild);
 85                                }
 86                            }
 87                        }
 88                        Ext.MessageBox.show(
 89                        {
 90                            title: '???????',
 91                            msg: '?????:',
 92                            buttons: Ext.MessageBox.OKCANCEL,
 93                            prompt: true,
 94                            fn: handleCreate
 95                        });
 96                    }
 97                }
 98            },'-',
 99            {
100                text: '????',
101                tooltip: '????',
102                listeners:
103                {
104                    'click': function()
105                    {
106                        var selectedItem = tree.getSelectionModel().getSelectedNode();
107                        if (!selectedItem)
108                        {
109                            Ext.Msg.alert('??', '??????');
110                            return false;
111                        }
112                        handleCreate = function (btn, text, cBoxes)
113                        {
114                            if (btn == 'ok' && text)
115                            {
116                                var newNode = new Ext.tree.TreeNode(
117                                {
118                                    menu_item: text,
119                                    menu_url: '',
120                                    leaf: true,
121                                    allowChildren: false,
122                                    uiProvider: Ext.tree.ColumnNodeUI
123                                });
124                                if (selectedItem.isLeaf())
125                                {
126                                    selectedItem.parentNode.insertBefore(newNode, selectedItem.nextSibling);
127                                }
128                                else
129                                {
130                                    selectedItem.insertBefore(newNode, selectedItem.firstChild);
131                                }
132                            }
133                        }
134                        Ext.MessageBox.show(
135                        {
136                            title: '??????',
137                            msg: '????:',
138                            buttons: Ext.MessageBox.OKCANCEL,
139                            prompt: true,
140                            fn: handleCreate
141                        });
142                    }
143                }
144            },'-',
145            {
146                text: '??????',
147                tooltip: '??????',
148                listeners:
149                {
150                  'click': function()
151                  {
152                      var selectedItem = tree.getSelectionModel().getSelectedNode();
153                      if (!selectedItem)
154                      {
155                          Ext.Msg.alert('??', '???????');
156                          return false;
157                      }
158                      handleDelete = function (btn)
159                      {
160                          if (btn == 'ok')
161                          {
162                              selectedItem.remove();
163                          }
164                      }
165                      Ext.MessageBox.show(
166                      {
167                          title: '???',
168                          msg: '????',
169                          buttons: Ext.MessageBox.OKCANCEL,
170                          fn: handleDelete
171                      });
172                  }
173                }
174            },'-'
175        ],
176        columns:
177        [
178            {
179                header: '????',
180                width: 200,
181                dataIndex: 'task'
182            },
183            {
184                header: '???',
185                width: 150,
186                dataIndex: 'duration'
187            },
188            {
189                header: '??',
190                width: 120,
191                dataIndex: 'user'
192            },is_show
193        ],
194       loader: new Ext.tree.TreeLoader({
195            dataUrl:'web_config.php?require=tree',
196            uiProviders:{
197                'col': Ext.tree.ColumnNodeUI
198            }
199        }),
200        root: root
201    });
202    tree.expandAll();
203	var viewport = new Ext.Viewport({
204		layout:'border',
205			items    : [
206			tree
207		]
208	});
209});