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 |
1 | 1 | Exxon Mobil | Ex | $339,938.00 | $36,130.00 | $376,068.00 | $23,333.00 | $352,735.00 | 0.3908321317812631 | 0.1635465970711356 | 0.7655077642627108 | 0.8962719511837398 | 0.9152660131304193 | 0.20398846036614993 | 0.24675856594279177 | 0.9618769870986894 | 0.19998275960908152 |
2 | 2 | Wal-Mart Stores | WS | $315,654.00 | $11,231.00 | $326,885.00 | $24,342.00 | $302,543.00 | 0.39266057384251773 | 0.489137430935906 | 0.7330287257695045 | 0.4402683629502284 | 0.6324946186394371 | 0.001147605982812605 | 0.18733198117970118 | 0.042307990332894896 | 0.6989806405330861 |
3 | 3 | Royal Dutch Shell | RDS | $306,731.00 | $25,311.00 | $332,042.00 | $56,231.20 | $275,810.80 | 0.8260996841705686 | 0.07338028552861364 | 0.9818134582201921 | 0.7591715062886251 | 0.4089724205901333 | 0.645001061242322 | 0.8847415669927876 | 0.7225679157321578 | 0.892389028784121 |
4 | 4 | BP | B | $267,600.00 | $22,341.00 | $289,941.00 | $71,923.40 | $218,017.60 | 0.7167713548839398 | 0.5302786625938343 | 0.6058342064096629 | 0.9569531568218634 | 0.3524941456565438 | 0.8450629071188738 | 0.7926481107746857 | 0.8306379048596042 | 0.7655279476748524 |
5 | 5 | General Motors | GM | $192,604.00 | -$10,567.00 | $182,037.00 | $52,934.00 | $129,103.00 | 0.2827409949326314 | 0.7216700553673172 | 0.6448842686544523 | 0.48683397520168326 | 0.19084941289822743 | 0.18974715327526215 | 0.9537125772008388 | 0.13304017797654466 | 0.9817749473688435 |
6 | 6 | Chevron | C | $189,481.00 | $14,099.00 | $203,580.00 | $12,023.50 | $191,556.50 | 0.5329318424722205 | 0.8159744310399333 | 0.5719638815528327 | 0.14832632591263084 | 0.18302388177553763 | 0.9692263543786588 | 0.47732444710724176 | 0.8061675188626449 | 0.024533354718377032 |
7 | 7 | DaimlerChrysler | DC | $186,106.30 | $3,536.30 | $189,642.60 | $42,734.00 | $146,908.60 | 0.19454145148162705 | 0.4250585266165665 | 0.4435153215158858 | 0.3164306042509448 | 0.27721648220193873 | 0.8318398906945832 | 0.46144794120828925 | 0.6010798491516403 | 0.3403340246904565 |
8 | 8 | Toyota Motor | TM | $185,805.00 | $12,119.60 | $197,924.60 | $57,023.40 | $140,901.20 | 0.4488955142332849 | 0.48520513342385896 | 0.5381789836586119 | 0.09391593093979611 | 0.49231600005604936 | 0.3523322624113616 | 0.1163596184700697 | 0.15057210691164746 | 0.739696684348957 |
9 | 9 | Ford Motor | FM | $177,210.00 | $2,024.00 | $179,234.00 | $22,896.00 | $156,338.00 | 0.4795303200755099 | 0.6388096083389443 | 0.5786948564606085 | 0.19072068086705696 | 0.8107810520909893 | 0.6368079615530033 | 0.476057062544599 | 0.9777761849488771 | 0.6148979808074246 |
10 | 10 | ConocoPhillips | CP | $166,683.00 | $13,529.00 | $180,212.00 | $72,456.00 | $107,756.00 | 0.829902732429763 | 0.2031695233303814 | 0.07034086550948104 | 0.28051595473657787 | 0.5459534963839474 | 0.9348099395932443 | 0.7006708196480826 | 0.05984477105323127 | 0.9061363171604719 |
11 | 11 | General Electric | GE | $157,153.00 | $16,353.00 | $173,506.00 | $16,912.50 | $156,593.50 | 0.9656564144466291 | 0.8483559833259537 | 0.5128142448943847 | 0.8186785634585958 | 0.9850465874170189 | 0.12953234304216243 | 0.006500942951663813 | 0.2325202352465241 | 0.445335421794681 |
12 | 12 | Total | T | $152,360.70 | $15,250.00 | $152,360.72 | $74,236.50 | $78,124.22 | 0.7009581303976484 | 0.061436749431410975 | 0.624471442349533 | 0.3599395511041217 | 0.5274279438822782 | 0.6912490631596344 | 0.9586350631893057 | 0.13259618190449918 | 0.9662087130160961 |
13 | 13 | ING Group | IG | $138,235.30 | $8,958.90 | $147,194.20 | $52,012.90 | $95,181.30 | 0.6840527624423847 | 0.957762679741136 | 0.0779830560921091 | 0.27031083587321714 | 0.46795798886449 | 0.9511320299979351 | 0.26608464153677946 | 0.15465349748496138 | 0.7873477535448374 |
14 | 14 | Citigroup | CG | $131,045.00 | $24,589.00 | $155,634.00 | $90,342.00 | $65,292.00 | 0.5956268861841041 | 0.7030196050429867 | 0.07403984361420646 | 0.8071766419709683 | 0.5890372146899105 | 0.6293349235570507 | 0.36842827942468004 | 0.2833777329766034 | 0.8250277964092396 |
15 | 15 | AXA | A | $129,839.20 | $5,186.50 | $135,025.70 | $13,043.80 | $121,981.90 | 0.9342039174403416 | 0.12029218952316079 | 0.6462262675760795 | 0.8133811259714216 | 0.29158821699655557 | 0.025793148215745854 | 0.4278083004666733 | 0.5952206791824681 | 0.3926758251084572 |
16 | 16 | Allianz | AZ | $121,406.00 | $5,442.40 | $126,848.40 | $19,529.50 | $107,318.90 | 0.6883672833767931 | 0.4063716813564233 | 0.3262563402436949 | 0.17445911055841323 | 0.7022678614216546 | 0.4011764497804069 | 0.04603372455332133 | 0.6427203165126611 | 0.5193447078092812 |
17 | 17 | Volkswagen | VW | $118,376.60 | $1,391.70 | $119,768.30 | $84,472.70 | $35,295.60 | 0.9988146870324952 | 0.41194475544873166 | 0.8497386348014151 | 0.07912333530199844 | 0.6579511638957454 | 0.4265324851138821 | 0.7675141101461509 | 0.707787169367599 | 0.732435320872562 |
18 | 18 | Fortis | F | $112,351.40 | $4,896.30 | $117,247.70 | $83,473.00 | $33,774.70 | 0.035620692970246726 | 0.8636657518945443 | 0.45920284163999003 | 0.8232620332100511 | 0.6390063785268165 | 0.9439031486239988 | 0.23461919191759462 | 0.9213196218049635 | 0.9878831110801876 |
19 | 19 | Crédit Agricole | CA | $110,764.60 | $7,434.30 | $118,198.90 | $14,567.40 | $103,631.50 | 0.19175984252312572 | 0.915846843051118 | 0.7012755167188185 | 0.28130651355901937 | 0.8963911677654373 | 0.31541216269556127 | 0.6886830355705287 | 0.23700390587220066 | 0.9163929701194107 |
20 | 20 | American Intl. Group | AIG | $108,905.00 | $10,477.00 | $119,382.00 | $10,533.00 | $108,849.00 | 0.2928056254783613 | 0.6815959280660862 | 0.45737070665575463 | 0.31105072274344336 | 0.4710008213963146 | 0.37768594525296706 | 0.5882605978908317 | 0.8968434425765581 | 0.9210645671799802 |
1 | 1 | Exxon Mobil | Ex | $339,938.00 | $36,130.00 | $376,068.00 | $23,333.00 | $352,735.00 | 0.3908321317812631 | 0.1635465970711356 | 0.7655077642627108 | 0.8962719511837398 | 0.9152660131304193 | 0.20398846036614993 | 0.24675856594279177 | 0.9618769870986894 | 0.19998275960908152 |
2 | 2 | Wal-Mart Stores | WS | $315,654.00 | $11,231.00 | $326,885.00 | $24,342.00 | $302,543.00 | 0.39266057384251773 | 0.489137430935906 | 0.7330287257695045 | 0.4402683629502284 | 0.6324946186394371 | 0.001147605982812605 | 0.18733198117970118 | 0.042307990332894896 | 0.6989806405330861 |
3 | 3 | Royal Dutch Shell | RDS | $306,731.00 | $25,311.00 | $332,042.00 | $56,231.20 | $275,810.80 | 0.8260996841705686 | 0.07338028552861364 | 0.9818134582201921 | 0.7591715062886251 | 0.4089724205901333 | 0.645001061242322 | 0.8847415669927876 | 0.7225679157321578 | 0.892389028784121 |
4 | 4 | BP | B | $267,600.00 | $22,341.00 | $289,941.00 | $71,923.40 | $218,017.60 | 0.7167713548839398 | 0.5302786625938343 | 0.6058342064096629 | 0.9569531568218634 | 0.3524941456565438 | 0.8450629071188738 | 0.7926481107746857 | 0.8306379048596042 | 0.7655279476748524 |
5 | 5 | General Motors | GM | $192,604.00 | -$10,567.00 | $182,037.00 | $52,934.00 | $129,103.00 | 0.2827409949326314 | 0.7216700553673172 | 0.6448842686544523 | 0.48683397520168326 | 0.19084941289822743 | 0.18974715327526215 | 0.9537125772008388 | 0.13304017797654466 | 0.9817749473688435 |
6 | 6 | Chevron | C | $189,481.00 | $14,099.00 | $203,580.00 | $12,023.50 | $191,556.50 | 0.5329318424722205 | 0.8159744310399333 | 0.5719638815528327 | 0.14832632591263084 | 0.18302388177553763 | 0.9692263543786588 | 0.47732444710724176 | 0.8061675188626449 | 0.024533354718377032 |
7 | 7 | DaimlerChrysler | DC | $186,106.30 | $3,536.30 | $189,642.60 | $42,734.00 | $146,908.60 | 0.19454145148162705 | 0.4250585266165665 | 0.4435153215158858 | 0.3164306042509448 | 0.27721648220193873 | 0.8318398906945832 | 0.46144794120828925 | 0.6010798491516403 | 0.3403340246904565 |
8 | 8 | Toyota Motor | TM | $185,805.00 | $12,119.60 | $197,924.60 | $57,023.40 | $140,901.20 | 0.4488955142332849 | 0.48520513342385896 | 0.5381789836586119 | 0.09391593093979611 | 0.49231600005604936 | 0.3523322624113616 | 0.1163596184700697 | 0.15057210691164746 | 0.739696684348957 |
9 | 9 | Ford Motor | FM | $177,210.00 | $2,024.00 | $179,234.00 | $22,896.00 | $156,338.00 | 0.4795303200755099 | 0.6388096083389443 | 0.5786948564606085 | 0.19072068086705696 | 0.8107810520909893 | 0.6368079615530033 | 0.476057062544599 | 0.9777761849488771 | 0.6148979808074246 |
10 | 10 | ConocoPhillips | CP | $166,683.00 | $13,529.00 | $180,212.00 | $72,456.00 | $107,756.00 | 0.829902732429763 | 0.2031695233303814 | 0.07034086550948104 | 0.28051595473657787 | 0.5459534963839474 | 0.9348099395932443 | 0.7006708196480826 | 0.05984477105323127 | 0.9061363171604719 |
11 | 11 | General Electric | GE | $157,153.00 | $16,353.00 | $173,506.00 | $16,912.50 | $156,593.50 | 0.9656564144466291 | 0.8483559833259537 | 0.5128142448943847 | 0.8186785634585958 | 0.9850465874170189 | 0.12953234304216243 | 0.006500942951663813 | 0.2325202352465241 | 0.445335421794681 |
12 | 12 | Total | T | $152,360.70 | $15,250.00 | $152,360.72 | $74,236.50 | $78,124.22 | 0.7009581303976484 | 0.061436749431410975 | 0.624471442349533 | 0.3599395511041217 | 0.5274279438822782 | 0.6912490631596344 | 0.9586350631893057 | 0.13259618190449918 | 0.9662087130160961 |
13 | 13 | ING Group | IG | $138,235.30 | $8,958.90 | $147,194.20 | $52,012.90 | $95,181.30 | 0.6840527624423847 | 0.957762679741136 | 0.0779830560921091 | 0.27031083587321714 | 0.46795798886449 | 0.9511320299979351 | 0.26608464153677946 | 0.15465349748496138 | 0.7873477535448374 |
14 | 14 | Citigroup | CG | $131,045.00 | $24,589.00 | $155,634.00 | $90,342.00 | $65,292.00 | 0.5956268861841041 | 0.7030196050429867 | 0.07403984361420646 | 0.8071766419709683 | 0.5890372146899105 | 0.6293349235570507 | 0.36842827942468004 | 0.2833777329766034 | 0.8250277964092396 |
15 | 15 | AXA | A | $129,839.20 | $5,186.50 | $135,025.70 | $13,043.80 | $121,981.90 | 0.9342039174403416 | 0.12029218952316079 | 0.6462262675760795 | 0.8133811259714216 | 0.29158821699655557 | 0.025793148215745854 | 0.4278083004666733 | 0.5952206791824681 | 0.3926758251084572 |
16 | 16 | Allianz | AZ | $121,406.00 | $5,442.40 | $126,848.40 | $19,529.50 | $107,318.90 | 0.6883672833767931 | 0.4063716813564233 | 0.3262563402436949 | 0.17445911055841323 | 0.7022678614216546 | 0.4011764497804069 | 0.04603372455332133 | 0.6427203165126611 | 0.5193447078092812 |
17 | 17 | Volkswagen | VW | $118,376.60 | $1,391.70 | $119,768.30 | $84,472.70 | $35,295.60 | 0.9988146870324952 | 0.41194475544873166 | 0.8497386348014151 | 0.07912333530199844 | 0.6579511638957454 | 0.4265324851138821 | 0.7675141101461509 | 0.707787169367599 | 0.732435320872562 |
18 | 18 | Fortis | F | $112,351.40 | $4,896.30 | $117,247.70 | $83,473.00 | $33,774.70 | 0.035620692970246726 | 0.8636657518945443 | 0.45920284163999003 | 0.8232620332100511 | 0.6390063785268165 | 0.9439031486239988 | 0.23461919191759462 | 0.9213196218049635 | 0.9878831110801876 |
19 | 19 | Crédit Agricole | CA | $110,764.60 | $7,434.30 | $118,198.90 | $14,567.40 | $103,631.50 | 0.19175984252312572 | 0.915846843051118 | 0.7012755167188185 | 0.28130651355901937 | 0.8963911677654373 | 0.31541216269556127 | 0.6886830355705287 | 0.23700390587220066 | 0.9163929701194107 |
20 | 20 | American Intl. Group | AIG | $108,905.00 | $10,477.00 | $119,382.00 | $10,533.00 | $108,849.00 | 0.2928056254783613 | 0.6815959280660862 | 0.45737070665575463 | 0.31105072274344336 | 0.4710008213963146 | 0.37768594525296706 | 0.5882605978908317 | 0.8968434425765581 | 0.9210645671799802 |
x1
2<div id="grid_group" style="margin:auto;"></div>
3
1521
2
3$(function () {
4//columns in data array : Sr No, Company Name, Revenues(domestic), Revenues(export), expenditure
5var 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
26for (var i = 0; i < data.length; i++) {
27var rdata = data[i];
28//fill rest of the columns with random data.
29rdata[8] = Math.random();
30rdata[9] = Math.random();
31rdata[10] = Math.random();
32rdata[11] = Math.random();
33rdata[12] = Math.random();
34rdata[13] = Math.random();
35rdata[14] = Math.random();
36rdata[15] = Math.random();
37rdata[16] = Math.random();
38}
39
40var obj = {
41height: 450,
42showTitle: false,
43freezeCols: 1,
44resizable: true,
45toolbar: {
46items: [{
47type: 'checkbox',
48label: 'zip',
49attr: 'id="export_zip"'
50},
51{
52type: 'textbox',
53label: 'Filename: ',
54attr: 'id="export_filename" placeholder="Enter filename"'
55},
56{
57type: 'select',
58label: 'Format: ',
59attr: 'id="export_format"',
60options: [{ xlsx: 'Excel', csv: 'Csv', htm: 'Html', json: 'Json'}]
61},
62{
63type: 'button',
64label: "Export",
65icon: 'ui-icon-arrowthickstop-1-s',
66listener: function () {
67this.exportData({
68url: "/pro/demos/exportData",
69format: $("#export_format").val(),
70zip: $("#export_zip").prop("checked"),
71filename: $("#export_filename").val(),
72render: true
73});
74}
75}]
76}
77};
78obj.columnTemplate = { width: 100, align: 'right' };
79obj.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{
85title: "Domestic",
86dataIndx: 3,
87format: '$##,###.00',
88dataType: "float"
89},
90{
91title: "Exports",
92dataIndx: 4,
93format: '$##,###.00',
94dataType: "float"
95},
96{
97title: "Total",
98width: 120,
99editable: false,
100dataIndx: 6,
101dataType: "float",
102format: '$##,###.00',
103formula: function (ui) {
104var rd = ui.rowData;
105return rd[3] + rd[4];
106}
107}
108]},
109{
110title: "Expenditure ($ millions)",
111dataType: "float",
112format: '$##,###.00',
113dataIndx: 5
114},
115{
116title: "Profits = Revenues - Expenditure",
117width: 140,
118dataType: "float",
119editable: false,
120dataIndx: 7,
121format: '$##,###.00',
122formula: function (ui) {
123var rd = ui.rowData;
124return 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{
144title: "Column", colModel: [{ title: "Column1" }, { title: "Column2"}]
145}
146];
147
148obj.dataModel = { data: data };
149
150var $grid = $("#grid_group").pqGrid(obj);
151});
152