PDA

View Full Version : set header text on grid



bublicov
27 Mar 2013, 11:17 PM
Hi All

I brought grid in a separate class. How can i set headers text on grid when use xtype ?


Ext.define('Test.view.MeterGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.MeterGrid',

header: false,
title: 'My Grid Panel',

initComponent: function() {
var me = this;

Ext.applyIf(me, {
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'date',
text: 'Date',
editor: {
xtype: 'datefield'
}
},
{
xtype: 'numbercolumn',
dataIndex: 'val_1',
text: 'Val_1'
},
{
xtype: 'numbercolumn',
dataIndex: 'val_2',
text: 'Val_2'
}
],
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {

})
]
});

me.callParent(arguments);
},

setHeaders: function() {
//How?
}
});

tbl1 and tbl2 contain similar data, but with different headlines


xtype: 'tabpanel',
activeTab: 0,
items: [
{
xtype: 'panel',
title: 'tbl1',
items: [
{
xtype: 'MeterGrid',
store: 'Meters1'
}
]
},
{
xtype: 'panel',
title: 'tbl2',
items: [
{
xtype: 'MeterGrid',
store: 'Meter2'
}
]
}
]

Farish
27 Mar 2013, 11:54 PM
Just add title config to your grids:



{
xtype: 'MeterGrid',
title: 'Meters1',
store: 'Meters1'
}

bublicov
28 Mar 2013, 12:45 AM
I mean headings of the columns on grid

Farish
28 Mar 2013, 1:11 AM
you have defined columns in your extended grid type. If you want to override those columns, you have to include columns config (with the new headers, dataIndex etc.) where you use that component. I dont know if there is any direct way to override just the headers of the columns you already have.

AssetWorks
28 Mar 2013, 6:04 AM
you can add an id to the column, do a


Ext.getCmp(id).setText(text);