13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Ext.define('KitchenSink.view.tree.CheckTree', {
    extend: 'Ext.tree.Panel',
    
    requires: [
        'Ext.data.TreeStore'
    ],
    xtype: 'check-tree',
    
    //<example>
    exampleTitle: 'Checkbox Selection in a TreePanel',
    exampleDescription: [
        '<p>This example shows simple checkbox selection in a tree. It is enabled on leaf nodes by simply',
        'setting <tt>checked:true/false</tt> at the node level.</p>',
        '<p>This example also shows loading an entire tree structure statically in one load call, rather than',
        'loading each node asynchronously.</p>'
    ].join(''),
    //</example>
    
    rootVisible: false,
    useArrows: true,
    frame: true,
    title: 'Check Tree',
    width: 250,
    height: 300,
    
    initComponent: function(){
 
        Ext.apply(this, {
            store: new Ext.data.TreeStore({
                proxy: {
                    type: 'ajax',
                    url: 'resources/data/tree/check-nodes.json'
                },
                sorters: [{
                    property: 'leaf',
                    direction: 'ASC'
                }, {
                    property: 'text',
                    direction: 'ASC'
                }]
            }),
            tbar: [{
                text: 'Get checked nodes',
                scope: this,
                handler: this.onCheckedNodesClick
            }]
        });
        this.callParent();
    },
    
    onCheckedNodesClick: function(){
        var records = this.getView().getChecked(),
            names = [];
                   
        Ext.Array.each(records, function(rec){
            names.push(rec.get('text'));
        });
                    
        Ext.MessageBox.show({
            title: 'Selected Nodes',
            msg: names.join('<br />'),
            icon: Ext.MessageBox.INFO
        });
    }
})