3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.ux.grid.TransformGrid
17 * @extends Ext.grid.Panel
18 * A Grid which creates itself from an existing HTML table element.
20 * 2007-03-01 Original version by Nige "Animal" White
21 * 2007-03-10 jvs Slightly refactored to reuse existing classes * @constructor
22 * @param {String/HTMLElement/Ext.Element} table The table element from which this grid will be created -
23 * The table MUST have some type of size defined for the grid to fill. The container will be
24 * automatically set to position relative if it isn't already.
25 * @param {Object} config A config object that sets properties on this grid and has two additional (optional)
26 * properties: fields and columns which allow for customizing data fields and columns for this grid.
28 Ext.define('Ext.ux.grid.TransformGrid', {
29 extend: 'Ext.grid.Panel',
31 constructor: function(table, config) {
32 config = Ext.apply({}, config);
33 table = this.table = Ext.get(table);
35 var configFields = config.fields || [],
36 configColumns = config.columns || [],
39 ct = table.insertSibling(),
40 headers = table.query("thead th"),
51 for (; i < len; ++i) {
57 fields.push(Ext.applyIf(configFields[i] || {}, {
59 mapping: 'td:nth(' + (i + 1) + ')/@innerHTML'
62 cols.push(Ext.applyIf(configColumns[i] || {}, {
65 width: col.offsetWidth,
74 width = table.getWidth() + 1;
78 height = config.height;
81 if (config.remove !== false) {
82 // Don't use table.remove() as that destroys the row/cell data in the table in
83 // IE6-7 so it cannot be read by the data reader.
84 data.parentNode.removeChild(data);
102 autoHeight: height ? false : true,
106 this.callParent([config]);
109 onDestroy: function() {