2 * @class Ext.ux.grid.TransformGrid
3 * @extends Ext.grid.Panel
4 * A Grid which creates itself from an existing HTML table element.
6 * 2007-03-01 Original version by Nige "Animal" White
7 * 2007-03-10 jvs Slightly refactored to reuse existing classes * @constructor
8 * @param {String/HTMLElement/Ext.Element} table The table element from which this grid will be created -
9 * The table MUST have some type of size defined for the grid to fill. The container will be
10 * automatically set to position relative if it isn't already.
11 * @param {Object} config A config object that sets properties on this grid and has two additional (optional)
12 * properties: fields and columns which allow for customizing data fields and columns for this grid.
14 Ext.define('Ext.ux.grid.TransformGrid', {
15 extend: 'Ext.grid.Panel',
17 constructor: function(table, config) {
18 config = Ext.apply({}, config);
19 table = this.table = Ext.get(table);
21 var configFields = config.fields || [],
22 configColumns = config.columns || [],
25 ct = table.insertSibling(),
26 headers = table.query("thead th"),
37 for (; i < len; ++i) {
43 fields.push(Ext.applyIf(configFields[i] || {}, {
45 mapping: 'td:nth(' + (i + 1) + ')/@innerHTML'
48 cols.push(Ext.applyIf(configColumns[i] || {}, {
51 width: col.offsetWidth,
60 width = table.getWidth();
64 height = config.height;
67 if (config.remove !== false) {
68 // Don't use table.remove() as that destroys the row/cell data in the table in
69 // IE6-7 so it cannot be read by the data reader.
70 data.parentNode.removeChild(data);
88 autoHeight: height ? false : true,
92 this.callParent([config]);
95 onDestroy: function() {