This example shows export of grouped columns in the grid.

 
Some No
Company
Balance Sheet
Rank
Column
Company A
Company B
Revenues ($ millions)
Expenditure ($ millions)
Profits = Revenues - Expenditure
Rank1
Rank2
Rank 3
Column1
Column2
Domestic
Exports
Total
Rank21
Rank 22
Rank 221
Rank 222
Rank 2221
Rank 2222
Rank 2223
 
 
 
Some No
Company
Balance Sheet
Rank
Column
Company A
Company B
Revenues ($ millions)
Expenditure ($ millions)
Profits = Revenues - Expenditure
Rank1
Rank2
Rank 3
Column1
Column2
Domestic
Exports
Total
Rank21
Rank 22
Rank 221
Rank 222
Rank 2221
Rank 2222
Rank 2223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11Exxon MobilEx$339,938.00$36,130.00$376,068.00$23,333.00$352,735.000.39083213178126310.16354659707113560.76550776426271080.89627195118373980.91526601313041930.203988460366149930.246758565942791770.96187698709868940.19998275960908152
22Wal-Mart StoresWS$315,654.00$11,231.00$326,885.00$24,342.00$302,543.000.392660573842517730.4891374309359060.73302872576950450.44026836295022840.63249461863943710.0011476059828126050.187331981179701180.0423079903328948960.6989806405330861
33Royal Dutch ShellRDS$306,731.00$25,311.00$332,042.00$56,231.20$275,810.800.82609968417056860.073380285528613640.98181345822019210.75917150628862510.40897242059013330.6450010612423220.88474156699278760.72256791573215780.892389028784121
44BPB$267,600.00$22,341.00$289,941.00$71,923.40$218,017.600.71677135488393980.53027866259383430.60583420640966290.95695315682186340.35249414565654380.84506290711887380.79264811077468570.83063790485960420.7655279476748524
55General MotorsGM$192,604.00-$10,567.00$182,037.00$52,934.00$129,103.000.28274099493263140.72167005536731720.64488426865445230.486833975201683260.190849412898227430.189747153275262150.95371257720083880.133040177976544660.9817749473688435
66ChevronC$189,481.00$14,099.00$203,580.00$12,023.50$191,556.500.53293184247222050.81597443103993330.57196388155283270.148326325912630840.183023881775537630.96922635437865880.477324447107241760.80616751886264490.024533354718377032
77DaimlerChryslerDC$186,106.30$3,536.30$189,642.60$42,734.00$146,908.600.194541451481627050.42505852661656650.44351532151588580.31643060425094480.277216482201938730.83183989069458320.461447941208289250.60107984915164030.3403340246904565
88Toyota MotorTM$185,805.00$12,119.60$197,924.60$57,023.40$140,901.200.44889551423328490.485205133423858960.53817898365861190.093915930939796110.492316000056049360.35233226241136160.11635961847006970.150572106911647460.739696684348957
99Ford MotorFM$177,210.00$2,024.00$179,234.00$22,896.00$156,338.000.47953032007550990.63880960833894430.57869485646060850.190720680867056960.81078105209098930.63680796155300330.4760570625445990.97777618494887710.6148979808074246
1010ConocoPhillipsCP$166,683.00$13,529.00$180,212.00$72,456.00$107,756.000.8299027324297630.20316952333038140.070340865509481040.280515954736577870.54595349638394740.93480993959324430.70067081964808260.059844771053231270.9061363171604719
1111General ElectricGE$157,153.00$16,353.00$173,506.00$16,912.50$156,593.500.96565641444662910.84835598332595370.51281424489438470.81867856345859580.98504658741701890.129532343042162430.0065009429516638130.23252023524652410.445335421794681
1212TotalT$152,360.70$15,250.00$152,360.72$74,236.50$78,124.220.70095813039764840.0614367494314109750.6244714423495330.35993955110412170.52742794388227820.69124906315963440.95863506318930570.132596181904499180.9662087130160961
1313ING GroupIG$138,235.30$8,958.90$147,194.20$52,012.90$95,181.300.68405276244238470.9577626797411360.07798305609210910.270310835873217140.467957988864490.95113202999793510.266084641536779460.154653497484961380.7873477535448374
1414CitigroupCG$131,045.00$24,589.00$155,634.00$90,342.00$65,292.000.59562688618410410.70301960504298670.074039843614206460.80717664197096830.58903721468991050.62933492355705070.368428279424680040.28337773297660340.8250277964092396
1515AXAA$129,839.20$5,186.50$135,025.70$13,043.80$121,981.900.93420391744034160.120292189523160790.64622626757607950.81338112597142160.291588216996555570.0257931482157458540.42780830046667330.59522067918246810.3926758251084572
1616AllianzAZ$121,406.00$5,442.40$126,848.40$19,529.50$107,318.900.68836728337679310.40637168135642330.32625634024369490.174459110558413230.70226786142165460.40117644978040690.046033724553321330.64272031651266110.5193447078092812
1717VolkswagenVW$118,376.60$1,391.70$119,768.30$84,472.70$35,295.600.99881468703249520.411944755448731660.84973863480141510.079123335301998440.65795116389574540.42653248511388210.76751411014615090.7077871693675990.732435320872562
1818FortisF$112,351.40$4,896.30$117,247.70$83,473.00$33,774.700.0356206929702467260.86366575189454430.459202841639990030.82326203321005110.63900637852681650.94390314862399880.234619191917594620.92131962180496350.9878831110801876
1919Crédit AgricoleCA$110,764.60$7,434.30$118,198.90$14,567.40$103,631.500.191759842523125720.9158468430511180.70127551671881850.281306513559019370.89639116776543730.315412162695561270.68868303557052870.237003905872200660.9163929701194107
2020American Intl. GroupAIG$108,905.00$10,477.00$119,382.00$10,533.00$108,849.000.29280562547836130.68159592806608620.457370706655754630.311050722743443360.47100082139631460.377685945252967060.58826059789083170.89684344257655810.9210645671799802
11Exxon MobilEx$339,938.00$36,130.00$376,068.00$23,333.00$352,735.000.39083213178126310.16354659707113560.76550776426271080.89627195118373980.91526601313041930.203988460366149930.246758565942791770.96187698709868940.19998275960908152
22Wal-Mart StoresWS$315,654.00$11,231.00$326,885.00$24,342.00$302,543.000.392660573842517730.4891374309359060.73302872576950450.44026836295022840.63249461863943710.0011476059828126050.187331981179701180.0423079903328948960.6989806405330861
33Royal Dutch ShellRDS$306,731.00$25,311.00$332,042.00$56,231.20$275,810.800.82609968417056860.073380285528613640.98181345822019210.75917150628862510.40897242059013330.6450010612423220.88474156699278760.72256791573215780.892389028784121
44BPB$267,600.00$22,341.00$289,941.00$71,923.40$218,017.600.71677135488393980.53027866259383430.60583420640966290.95695315682186340.35249414565654380.84506290711887380.79264811077468570.83063790485960420.7655279476748524
55General MotorsGM$192,604.00-$10,567.00$182,037.00$52,934.00$129,103.000.28274099493263140.72167005536731720.64488426865445230.486833975201683260.190849412898227430.189747153275262150.95371257720083880.133040177976544660.9817749473688435
66ChevronC$189,481.00$14,099.00$203,580.00$12,023.50$191,556.500.53293184247222050.81597443103993330.57196388155283270.148326325912630840.183023881775537630.96922635437865880.477324447107241760.80616751886264490.024533354718377032
77DaimlerChryslerDC$186,106.30$3,536.30$189,642.60$42,734.00$146,908.600.194541451481627050.42505852661656650.44351532151588580.31643060425094480.277216482201938730.83183989069458320.461447941208289250.60107984915164030.3403340246904565
88Toyota MotorTM$185,805.00$12,119.60$197,924.60$57,023.40$140,901.200.44889551423328490.485205133423858960.53817898365861190.093915930939796110.492316000056049360.35233226241136160.11635961847006970.150572106911647460.739696684348957
99Ford MotorFM$177,210.00$2,024.00$179,234.00$22,896.00$156,338.000.47953032007550990.63880960833894430.57869485646060850.190720680867056960.81078105209098930.63680796155300330.4760570625445990.97777618494887710.6148979808074246
1010ConocoPhillipsCP$166,683.00$13,529.00$180,212.00$72,456.00$107,756.000.8299027324297630.20316952333038140.070340865509481040.280515954736577870.54595349638394740.93480993959324430.70067081964808260.059844771053231270.9061363171604719
1111General ElectricGE$157,153.00$16,353.00$173,506.00$16,912.50$156,593.500.96565641444662910.84835598332595370.51281424489438470.81867856345859580.98504658741701890.129532343042162430.0065009429516638130.23252023524652410.445335421794681
1212TotalT$152,360.70$15,250.00$152,360.72$74,236.50$78,124.220.70095813039764840.0614367494314109750.6244714423495330.35993955110412170.52742794388227820.69124906315963440.95863506318930570.132596181904499180.9662087130160961
1313ING GroupIG$138,235.30$8,958.90$147,194.20$52,012.90$95,181.300.68405276244238470.9577626797411360.07798305609210910.270310835873217140.467957988864490.95113202999793510.266084641536779460.154653497484961380.7873477535448374
1414CitigroupCG$131,045.00$24,589.00$155,634.00$90,342.00$65,292.000.59562688618410410.70301960504298670.074039843614206460.80717664197096830.58903721468991050.62933492355705070.368428279424680040.28337773297660340.8250277964092396
1515AXAA$129,839.20$5,186.50$135,025.70$13,043.80$121,981.900.93420391744034160.120292189523160790.64622626757607950.81338112597142160.291588216996555570.0257931482157458540.42780830046667330.59522067918246810.3926758251084572
1616AllianzAZ$121,406.00$5,442.40$126,848.40$19,529.50$107,318.900.68836728337679310.40637168135642330.32625634024369490.174459110558413230.70226786142165460.40117644978040690.046033724553321330.64272031651266110.5193447078092812
1717VolkswagenVW$118,376.60$1,391.70$119,768.30$84,472.70$35,295.600.99881468703249520.411944755448731660.84973863480141510.079123335301998440.65795116389574540.42653248511388210.76751411014615090.7077871693675990.732435320872562
1818FortisF$112,351.40$4,896.30$117,247.70$83,473.00$33,774.700.0356206929702467260.86366575189454430.459202841639990030.82326203321005110.63900637852681650.94390314862399880.234619191917594620.92131962180496350.9878831110801876
1919Crédit AgricoleCA$110,764.60$7,434.30$118,198.90$14,567.40$103,631.500.191759842523125720.9158468430511180.70127551671881850.281306513559019370.89639116776543730.315412162695561270.68868303557052870.237003905872200660.9163929701194107
2020American Intl. GroupAIG$108,905.00$10,477.00$119,382.00$10,533.00$108,849.000.29280562547836130.68159592806608620.457370706655754630.311050722743443360.47100082139631460.377685945252967060.58826059789083170.89684344257655810.9210645671799802
Loading...

152
 
1
2
3
    $(function () {
4
        //columns in data array : Sr No, Company Name, Revenues(domestic), Revenues(export), expenditure
5
        var data = [[1, 'Exxon Mobil', 'Ex', 339938.0, 36130.0, 23333.0],
6
            [2, 'Wal-Mart Stores', 'WS', 315654.0, 11231.0, 24342.0],
7
            [3, 'Royal Dutch Shell', 'RDS', 306731.0, 25311.0, 56231.2],
8
            [4, 'BP', 'B', 267600.0, 22341.0, 71923.4],
9
            [5, 'General Motors', 'GM', 192604.0, -10567.0, 52934.0],
10
            [6, 'Chevron', 'C', 189481.0, 14099.0, 12023.5],
11
            [7, 'DaimlerChrysler', 'DC', 186106.3, 3536.3, 42734.0],
12
            [8, 'Toyota Motor', 'TM', 185805.0, 12119.6, 57023.4],
13
            [9, 'Ford Motor', 'FM', 177210.0, 2024.0, 22896.0],
14
            [10, 'ConocoPhillips', 'CP', 166683.0, 13529.0, 72456.0],
15
            [11, 'General Electric', 'GE', 157153.0, 16353.0, 16912.5],
16
            [12, 'Total', 'T', '152360.7', 15250.0, 74236.5],
17
            [13, 'ING Group', 'IG', 138235.3, 8958.9, 52012.9],
18
            [14, 'Citigroup', 'CG', 131045.0, 24589.0, 90342.0],
19
            [15, 'AXA', 'A', 129839.2, 5186.5, 13043.8],
20
            [16, 'Allianz', 'AZ', 121406.0, 5442.4, 19529.5],
21
            [17, 'Volkswagen', 'VW', 118376.6, 1391.7, 84472.7],
22
            [18, 'Fortis', 'F', 112351.4, 4896.3, 83473.0],
23
            [19, 'Crédit Agricole', 'CA', 110764.6, 7434.3, 14567.4],
24
            [20, 'American Intl. Group', 'AIG', 108905.0, 10477.0, 10533.0]];
25
26
        for (var i = 0; i < data.length; i++) {
27
            var rdata = data[i];
28
            //fill rest of the columns with random data.
29
            rdata[8] = Math.random();
30
            rdata[9] = Math.random();
31
            rdata[10] = Math.random();
32
            rdata[11] = Math.random();
33
            rdata[12] = Math.random();
34
            rdata[13] = Math.random();
35
            rdata[14] = Math.random();
36
            rdata[15] = Math.random();
37
            rdata[16] = Math.random();
38
        }
39
40
        var obj = { 
41
            height: 450,            
42
            showTitle: false,
43
            freezeCols: 1,                        
44
            resizable: true,
45
            toolbar: {
46
                items: [{
47
                    type: 'checkbox',
48
                    label: 'zip',
49
                    attr: 'id="export_zip"'
50
                },
51
                {
52
                    type: 'textbox',
53
                    label: 'Filename: ',                
54
                    attr: 'id="export_filename" placeholder="Enter filename"'                 
55
                },
56
                {
57
                    type: 'select',
58
                    label: 'Format: ',                
59
                    attr: 'id="export_format"',
60
                    options: [{ xlsx: 'Excel', csv: 'Csv', htm: 'Html', json: 'Json'}]
61
                },
62
                {
63
                    type: 'button',
64
                    label: "Export",
65
                    icon: 'ui-icon-arrowthickstop-1-s',
66
                    listener: function () {
67
                        this.exportData({
68
                            url: "/pro/demos/exportData",
69
                            format: $("#export_format").val(),
70
                            zip: $("#export_zip").prop("checked"),
71
                            filename: $("#export_filename").val(),
72
                            render: true
73
                        });
74
                    }
75
                }]
76
            }
77
        };
78
        obj.columnTemplate = { width: 100, align: 'right' };
79
        obj.colModel = [
80
            { title: "Some No", colModel: [] },
81
            { title: "Company", width: 140, align: "center", colModel: [{ title: "Company A" }, { title: "Company B"}] },
82
            { title: "Balance Sheet", align: "center", colModel: [
83
                { title: "Revenues ($ millions)", dataType: "float", align: "center", colModel: [
84
                    {
85
                        title: "Domestic",
86
                        dataIndx: 3,
87
                        format: '$##,###.00',
88
                        dataType: "float"
89
                    },
90
                    {
91
                        title: "Exports",
92
                        dataIndx: 4,
93
                        format: '$##,###.00',
94
                        dataType: "float"
95
                    },
96
                    {
97
                        title: "Total",
98
                        width: 120,
99
                        editable: false,
100
                        dataIndx: 6,
101
                        dataType: "float",
102
                        format: '$##,###.00',
103
                        formula: function (ui) {                           
104
                            var rd = ui.rowData;
105
                            return rd[3] + rd[4];
106
                        }
107
                    }
108
                ]},
109
                {
110
                    title: "Expenditure ($ millions)",
111
                    dataType: "float",
112
                    format: '$##,###.00',
113
                    dataIndx: 5
114
                },
115
                {
116
                    title: "Profits = Revenues - Expenditure",
117
                    width: 140,
118
                    dataType: "float",
119
                    editable: false,
120
                    dataIndx: 7,
121
                    format: '$##,###.00',
122
                    formula: function (ui) {                        
123
                        var rd = ui.rowData;
124
                        return rd[6] - rd[5];
125
                    }
126
                }
127
            ]},        
128
            { title: "Rank", align: 'center', colModel: [
129
                { title: "Rank1" }, 
130
                { title: "Rank2", colModel: [
131
                    { title: "Rank21" },
132
                    { title: "Rank 22", colModel: [
133
                        { title: "Rank 221" },
134
                        { title: "Rank 222", colModel: [
135
                            { title: "Rank 2221" },
136
                            { title: "Rank 2222" },
137
                            { title: "Rank 2223" }
138
                        ]}
139
                    ]}                    
140
                ]},
141
                { title: "Rank 3" }
142
            ]},
143
            {
144
                title: "Column", colModel: [{ title: "Column1" }, { title: "Column2"}]
145
            }
146
        ];
147
148
        obj.dataModel = { data: data };
149
150
        var $grid = $("#grid_group").pqGrid(obj);
151
    });
152