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
Ext.define('KitchenSink.view.grid.GroupedHeaderGrid', {
    extend: 'Ext.grid.Panel',
    xtype: 'grouped-header-grid',
    store: 'Companies',
    columnLines: true,
    height: 350,
    title: 'Grouped Header Grid',
    viewConfig: {
        stripeRows: true
    },
    //<example>
    exampleDescription: [
        '<p>This example shows how to create a grid with column headers which are nested within category headers.</p>',
        '<p>Category headers do not reference Model fields via a <code>dataIndex</code>, rather they contain ',
        'child header definitions (which may themselves either contain a <code>dataIndex</code> or more levels of headers).</p>'
    ],
    themes: {
        classic: {
            width: 600,
            lastUpdatedColumnWidth: 85,
            percentChangeColumnWidth: 75
        },
        neptune: {
            width: 675,
            lastUpdatedColumnWidth: 115,
            percentChangeColumnWidth: 100
        }
    },
    //</example>
 
    initComponent: function () {
        this.width = this.themeInfo.width;
        this.columns = [{
                text     : 'Company',
                flex     : 1,
                sortable : false,
                dataIndex: 'company'
            }, {
                text: 'Stock Price',
                columns: [{
                    text     : 'Price',
                    width    : 75,
                    sortable : true,
                    renderer : 'usMoney',
                    dataIndex: 'price'
                }, {
                    text     : 'Change',
                    width    : 80,
                    sortable : true,
                    renderer :  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;
                    },
                    dataIndex: 'change'
                }, {
                    text     : '% Change',
                    width    : this.themeInfo.percentChangeColumnWidth,
                    sortable : true,
                    renderer : 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;
                    },
                    dataIndex: 'pctChange'
                }]
            }, {
                text     : 'Last Updated',
                width    : this.themeInfo.lastUpdatedColumnWidth,
                sortable : true,
                renderer : Ext.util.Format.dateRenderer('m/d/Y'),
                dataIndex: 'lastChange'
            }];
 
        this.callParent();
    }
});