PDA

View Full Version : [FIXED]pr2: Ext.grid.GridPanel - config preventHader not working



kyr0
25 Feb 2011, 4:58 AM
Hi again,

using:

{
xtype: 'gridpanel',
...
preventHeader: true
}

has no visible effect.

I will search for a solution and post a patch.

Best regards,
Aron

kyr0
25 Feb 2011, 7:23 AM
re,

the headers of the Grid are created in Ext.grid.Section which does not receive the preventHeader configuration currently. So the override to transmit the configuration to the section will be:


// Fix: Transmit config to section panel
var gridSectionCfg = {
xtype: 'gridsection',
preventHeader: this.preventHeader
};

// Do it on the fly...
Ext4.grid.GridPanel.override({

/**
* @cfg {Mixed} colModel/headers
*/
initComponent: function() {
if (this.columnLines) {
this.cls = (this.cls || '') + ' ' + Ext.baseCSSPrefix + 'grid-with-col-lines';
}
// <debug>
if (this.autoExpandColumn) {
console.warn("Ext.grid.GridPanel: autoExpandColumn has been removed in favor of flexible headers.");
}
if (this.trackMouseOver) {
console.warn('Ext.grid.GridPanel: trackMouseOver has been removed in favor of the trackOver configuration inherited from DataView. Pass in viewConfig: {trackOver: false}');
}
// </debug>


var sm = this.getSelectionModel();

this.layout = {
type: 'hbox',
align: 'stretch'
};

// Single pre-defined section
// the typical case.
if (!this.items) {
this.layout = 'fit';

// Fix: Transmit config to section panel
var gridSectionCfg = {
xtype: 'gridsection',
preventHeader: this.preventHeader
};
gridSectionCfg.headers = this.headers;
gridSectionCfg.features = this.features;
gridSectionCfg.viewConfig = this.viewConfig;
delete this.headers;
delete this.features;
delete this.viewConfig;
this.items = [gridSectionCfg];
}

this.store = Ext.data.StoreMgr.lookup(this.store);
this.store.on('load', this.onStoreLoad, this);
var items = this.items;
// Inject the selModel into each GridSection.
for (var i = 0, ln = items.length; i < ln; i++) {
if (items[i]) {
items[i].selModel = sm;
items[i].store = this.store;
}

// <debug>
if (items[i].columns) {
items[i].headers = items[i].columns;
console.warn("Ext.grid.GridPanel now specifies the headers via the headers configuration rather than columns.");
delete items[i].columns;
}
// <debug>

}
Ext.grid.GridPanel.superclass.initComponent.call(this);
}

});

Afterwards the initComponent of the section sets the height of the Ext.grid.HeaderContainer to 0,
if preventHeader is true. This is a quick fix solution. Would be better to not render the headers at all.
Also the initComponent of Ext.grid.Section is very unmodular..

Ext4.grid.Section.override({

/**
* @cfg {Boolean} preventHeader Prevent the grid section header from being shown. Defaults to false.
*/
preventHeader: false,

initComponent: function() {
var me = this,
scroll = me.scroll,
vertical = false,
horizontal = false;

// TODO: Remove in the future.
if (!me.locked) {
me.flex = 1;
}

me.bodyCls = me.bodyCls || '';
me.bodyCls += (' ' + me.extraBodyCls);

me.dockedItems = me.dockedItems || [];

// turn both on.
if (scroll === true || scroll === 'both') {
vertical = horizontal = true;
} else if (scroll === 'horizontal') {
horizontal = true;
} else if (scroll === 'vertical') {
vertical = true;
}
// All other values become 'none' or false.


if (vertical) {
me.verticalScroller = Ext.ComponentMgr.create({
dock: me.verticalScrollDock,
xtype: 'gridscroller'
});
}

if (horizontal) {
me.horizontalScroller = Ext.ComponentMgr.create({
xtype: 'gridscroller',
section: me,
dock: 'bottom'
});
}

// Quick fix: Simply set height to 0;
// TODO: Better solution would be to prevent
// rendering of the headers too.
var headerContainerCfg = {
items: me.headers
};

if (this.preventHeader) {
headerContainerCfg.height = 0;
}

/**
* @property headerCt -> colModel?
*/
me.headerCt = new Ext.grid.HeaderContainer(headerContainerCfg);
me.headerCt.on('headerresize', me.onHeaderResize, me);

me.features = me.features || [];
me.dockedItems = me.dockedItems || [];
me.dockedItems.unshift(me.headerCt);

me.callParent();
}
});

Best regards,
Aron

tobiu
25 Feb 2011, 9:01 AM
code-tags really help to make this readable :)

aconran
25 Feb 2011, 1:45 PM
preventHeader functionality will be going in shortly.

evant
13 Mar 2011, 6:29 PM
FYI the option is called hideHeaders.