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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Ext.define('KitchenSink.view.layout.Accordion', {
    extend: 'Ext.panel.Panel',
    
    requires: [
        'Ext.layout.container.Accordion',
        'Ext.grid.*',
        'KitchenSink.model.Company'
    ],
    xtype: 'layout-accordion',
    
    //<example>
    exampleTitle: 'Accordion Layout',
    exampleDescription: [
        '<p>Demonstrates usage of an accordion layout.</p>'
    ].join(''),
    
    themes: {
        classic: {
            colWidth: 75
        },
        
        neptune: {
            colWidth: 90
        }
    },
    //</example>
    
    layout: 'accordion',
    width: 500,
    height: 400,
    defaults: {
        bodyPadding: 10
    },
    
    initComponent: function() {
        Ext.apply(this, {
            items: [{
                bodyPadding: 0,
                xtype: 'grid',
                title: 'Array Grid (Click header to collapse)',
                hideCollapseTool: true,
                columnLines: true,
                viewConfig: {
                    stripeRows: true
                },
                store: new Ext.data.Store({
                    model: KitchenSink.model.Company,
                    data: KitchenSink.data.DataSets.company
                }),
                columns: [{
                    text     : 'Company',
                    flex     : 1,
                    sortable : false,
                    dataIndex: 'company'
                }, {
                    text     : 'Price',
                    width    : 75,
                    sortable : true,
                    renderer : 'usMoney',
                    dataIndex: 'price'
                }, {
                    text     : 'Change',
                    width    : 75,
                    sortable : true,
                    renderer : this.changeRenderer,
                    dataIndex: 'change'
                }, {
                    text     : '% Change',
                    width    : 90,
                    sortable : true,
                    renderer : this.pctChangeRenderer,
                    dataIndex: 'pctChange'
                }]
            }, {
                title: 'Accordion Item 2',
                html: 'Empty'
            }, {
                title: 'Accordion Item 3',
                html: 'Empty'
            }, {
                title: 'Accordion Item 4',
                html: 'Empty'
            }, {
                title: 'Accordion Item 5',
                html: 'Empty'
            }]
        });
        this.callParent();
    },
    
    changeRenderer: function(val) {
        if (val > 0) {
            return '<span style="color:green;">' + val + '</span>';
        } else if(val < 0) {
            return '<span style="color:red;">' + val + '</span>';
        }
        return val;
    },
    
    pctChangeRenderer: function(val){
        if (val > 0) {
            return '<span style="color:green;">' + val + '%</span>';
        } else if(val < 0) {
            return '<span style="color:red;">' + val + '%</span>';
        }
        return val;
    }
})