Ext.js5带子标题的标题的表格(6)
来源:互联网 发布:ubuntu启动项修复 编辑:程序博客网 时间:2024/04/30 00:06
代码来源:Ext.js5资源包
view
/** * This example shows how to create a grid with column headers which are nested within * category headers. *这个例子展示了怎么怎么创建有子标题的表格。我觉得有个瑕疵就是这个父标题没法控制子标题的显示隐藏。 *这个没有什么大的变化,还是在view中设置列嵌套列就行了。 * Category headers do not reference Model fields via a `dataIndex`, rather they contain * child header definitions (which may themselves either contain a `dataIndex` or more * levels of headers). */Ext.define('KitchenSink.view.grid.GroupedHeaderGrid', { extend: 'Ext.grid.Panel', xtype: 'grouped-header-grid', store: 'Companies', columnLines: true, height: 350, title: 'Grouped Header Grid', initComponent: function () { this.width = 675; this.columns = [{ text : 'Company', flex : 1, sortable : true, dataIndex: 'name' }, { //列中嵌套 text: 'Stock Price', columns: [{ text : 'Price', width : 75, sortable : true, formatter: '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 : 100, 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 : 115, sortable : true, formatter: 'date("m/d/Y")', dataIndex: 'lastChange' }]; //Sorting store //默认设置了一个公司的初始化按ASC顺序排列 Ext.getStore('Companies').sort({property:'name', direction:'ASC'}); this.callParent(); }});
store
Ext.define('KitchenSink.store.Companies', { extend: 'Ext.data.ArrayStore', alias: 'store.companies', model: 'KitchenSink.model.Company', data: [ [0, '3m Co', 71.72, 0.02, 0.03, '9/1 12:00am', 'Manufacturing'], [1, 'Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am', 'Manufacturing'], [2, 'Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am', 'Manufacturing'], [3, 'American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am', 'Finance'], [4, 'American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am', 'Services'], [5, 'AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am', 'Services'], [6, 'Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am', 'Manufacturing'], [7, 'Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am', 'Services'], [8, 'Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am', 'Finance'], [9, 'E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am', 'Manufacturing'], [10, 'Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am', 'Manufacturing'], [11, 'General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am', 'Manufacturing'], [12, 'General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am', 'Automotive'], [13, 'Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am', 'Computer'], [14, 'Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am', 'Manufacturing'], [15, 'Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am', 'Computer'], [16, 'International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am', 'Computer'], [17, 'Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am', 'Medical'], [18, 'JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am', 'Finance'], [19, 'McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am', 'Food'], [20, 'Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am', 'Medical'], [21, 'Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am', 'Computer'], [22, 'Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am', 'Medical'], [23, 'The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am', 'Food'], [24, 'The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am', 'Retail'], [25, 'The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am', 'Manufacturing'], [26, 'United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am', 'Computer'], [27, 'Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am', 'Services'], [28, 'Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am', 'Retail'], [29, 'Walt Disney Company (The) (Holding Company)', 29.89, 0.24, 0.81, '9/1 12:00am', 'Services'] ]}, function(cls) { var data = cls.prototype.config.data; for(var i = 0; i < data.length; i++){ data[i].push('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. '); }});
model
Ext.define('KitchenSink.model.Company', { extend: 'KitchenSink.model.Base', fields: [ {name: 'name'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}, {name: 'industry'}, {name: 'desc'}, // Trend begins with the cerrent price. Changes get pushed onto the end { name: 'trend', convert: function(value, record) { // Record creation call with no trend there: start with current price if (value === null) { return [record.get('price')]; } return Ext.isArray(value) ? value : [ value ]; } }, // Rating dependent upon performance 0 = best, 2 = worst { name: 'rating', type: 'int', convert: function(value, record) { var pct = record.get('pctChange'); if (pct < 0) return 2; if (pct < 1) return 1; return 0; } } ], // Override to keep the last 10 prices in the trend field set: function(fieldName, value) { if (fieldName === 'price') { this.callParent([{ price: value, trend: this.addToTrend(fieldName.price) }]); } else { if (typeof fieldName !== 'string' && 'price' in fieldName) { fieldName.trend = this.addToTrend(fieldName.price); } this.callParent(arguments); } }, // Override to keep the last 10 prices in the trend field addToTrend: function(value) { var trend = this.data.trend.concat(value); if (trend.length > 10) { Ext.Array.splice(trend, 0, trend.length - 10); } return trend; }});
0 0
- Ext.js5带子标题的标题的表格(6)
- Ext.js5的数组表格(3)
- Ext.js5的分组表格(4)
- Ext.js5的表格的排序扩展(7)
- Ext.js5的带分页的表格(10)
- Ext.js5的小部件表格(23)
- Ext.js5表格—多列的表格(比fieldcontainer布局效率很多)(48)
- 带标题的表格
- Ext.js5的面板(2)
- Ext.js5的列冻结(5)
- Ext.js5(编辑表格的内容celledit)(添加和删除的行为)(20)
- Ext.js5带工具条,按钮的表格(没有行为操作)(getReferences)(16)
- Ext.js5带过滤功能的表格(defaultListenerScope 作用域)(17)
- Ext.js5重新配置的表格(动态建立列和仓库)(18)
- Ext.js5的表格插件—展开和冻结和Ext.XTemplate(14)
- Ext.js5的能够伸展的表格(双击/选中enter键的时候有相反的行为)(21)
- Ext.js5用XML数据做的表(12)
- Ext.js5表单的文件上传(toast)(30)
- TabHost选项卡的功能和用法
- DIV+CSS布局和TABLE布局的优缺点讲解
- IOS 热更新,实时代码更新,动态更新,动态库framework
- hibernate、spring、c3p0整合(连接池)
- Android App的签名打包
- Ext.js5带子标题的标题的表格(6)
- Windows Server 2008 R2 安裝 Oracle 10g
- leetcode(303)Range Sum Query - Immutable js代码实现
- 设计模式之工厂模式
- Node.js 究竟是什么?
- 电源管理方案APM和ACPI比较
- binary search(java)
- 接口适配器模式
- sql学习笔记第一天