3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 Ext.onReady(function() {
9 Asia: ['Beijing', 'Tokyo'],
10 Europe: ['Berlin', 'London', 'Paris']
12 products = ['ProductX', 'ProductY'],
16 continentGroupRow = [],
21 * Example method that generates:
22 * 1) The column configuration for the grid
23 * 2) The column grouping configuration
24 * 3) The data for the store
25 * 4) The fields for the store
27 function generateConfig(){
29 numProducts = products.length;
31 Ext.iterate(structure, function(continent, cities){
32 continentGroupRow.push({
35 colspan: cities.length * numProducts
37 Ext.each(cities, function(city){
43 Ext.each(products, function(product){
49 dataIndex: city + product,
51 renderer: Ext.util.Format.usMoney
55 for(var i = 0; i < 20; ++i){
56 arr.push((Math.floor(Math.random()*11) + 1) * 100000);
63 // Run method to generate columns, fields, row grouping
68 * continentGroupRow at this point is:
70 * {header: 'Asia', colspan: 4, align: 'center'},
71 * {header: 'Europe', colspan: 6, align: 'center'}
74 * cityGroupRow at this point is:
76 * {header: 'Beijing', colspan: 2, align: 'center'},
77 * {header: 'Tokyo', colspan: 2, align: 'center'},
78 * {header: 'Berlin', colspan: 2, align: 'center'},
79 * {header: 'London', colspan: 2, align: 'center'},
80 * {header: 'Paris', colspan: 2, align: 'center'}
83 var group = new Ext.ux.grid.ColumnHeaderGroup({
84 rows: [continentGroupRow, cityGroupRow]
88 * fields at this point is:
90 * {type: 'int', name: 'BeijingProductX'},
91 * {type: 'int', name: 'BeijingProductY'},
92 * {type: 'int', name: 'TokyoProductX'},
93 * {type: 'int', name: 'TokyoProductY'},
94 * {type: 'int', name: 'BerlinProductX'},
95 * {type: 'int', name: 'BerlinProductY'},
96 * {type: 'int', name: 'LondonProductX'},
97 * {type: 'int', name: 'LondonProductY'},
98 * {type: 'int', name: 'ParisProductX'},
99 * {type: 'int', name: 'ParisProductY'}
102 * columns at this point is:
104 * {dataIndex: 'BeijingProductX', header: 'ProductX'},
105 * {dataIndex: 'BeijingProductY', header: 'ProductY'},
106 * {dataIndex: 'TokyoProductX', header: 'ProductX'},
107 * {dataIndex: 'TokyoProductY', header: 'ProductY'},
108 * {dataIndex: 'BerlinProductX', header: 'ProductX'},
109 * {dataIndex: 'BerlinProductY', header: 'ProductY'},
110 * {dataIndex: 'LondonProductX', header: 'ProductX'},
111 * {dataIndex: 'LondonProductY', header: 'ProductY'},
112 * {dataIndex: 'ParisProductX', header: 'ProductX'},
113 * {dataIndex: 'ParisProductY', header: 'ProductY'}
116 var grid = new Ext.grid.GridPanel({
117 renderTo: 'column-group-grid',
118 title: 'Sales By Location',
121 store: new Ext.data.ArrayStore({