Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / tree / check-tree.js
1 Ext.require([
2     'Ext.tree.*',
3     'Ext.data.*',
4     'Ext.window.MessageBox'
5 ]);
6
7 Ext.onReady(function() {
8     var store = Ext.create('Ext.data.TreeStore', {
9         proxy: {
10             type: 'ajax',
11             url: 'check-nodes.json'
12         },
13         sorters: [{
14             property: 'leaf',
15             direction: 'ASC'
16         }, {
17             property: 'text',
18             direction: 'ASC'
19         }]
20     });
21
22     var tree = Ext.create('Ext.tree.Panel', {
23         store: store,
24         rootVisible: false,
25         useArrows: true,
26         frame: true,
27         title: 'Check Tree',
28         renderTo: 'tree-div',
29         width: 200,
30         height: 250,
31         dockedItems: [{
32             xtype: 'toolbar',
33             items: {
34                 text: 'Get checked nodes',
35                 handler: function(){
36                     var records = tree.getView().getChecked(),
37                         names = [];
38                     
39                     Ext.Array.each(records, function(rec){
40                         names.push(rec.get('text'));
41                     });
42                     
43                     Ext.MessageBox.show({
44                         title: 'Selected Nodes',
45                         msg: names.join('<br />'),
46                         icon: Ext.MessageBox.INFO
47                     });
48                 }
49             }
50         }]
51     });
52 });