/* * Example method that generates: * 1) The column configuration for the grid * 2) The column grouping configuration * 3) The data for the store * 4) The fields for the store */ function generateConfig(){ var arr, numProducts = products.length;
//定义第二层城市列 Ext.each(cities, function(city){ fields.push({ type: 'int', name: city + continent }); columns.push({ dataIndex: city + continent, header: city, renderer: Ext.util.Format.usMoney }); });
arr = []; for(var i = 0; i < 20; ++i){ arr.push((Math.floor(Math.random()*11) + 1) * 100000); } data.push(arr); }); }
// Run method to generate columns, fields, row grouping generateConfig();
var group = new Ext.ux.grid.ColumnHeaderGroup({//插件 :前面两层表头 rows: [continentGroupRow] }); var grid = new Ext.grid.GridPanel({ renderTo: 'column-group-grid', title: 'Sales By Location', width: 1000, height: 400, store: new Ext.data.ArrayStore({ fields: fields, data: data }), columns: columns, viewConfig: { forceFit: true }, plugins: group }); }); </script> </html>