PDA

View Full Version : How to change grid column header name



dusoo
9 Mar 2011, 1:56 AM
Hi,

is there a way to change column header name ?
Let's say on button click, I would like to change column name "Instance" to "Inst"
Thanks,
D.


var grid = new Ext.grid.GridPanel({
store: store,
columns: [new Ext.grid.RowNumberer({width: 30}),
{header: "Date", width: 50, dataIndex: 'timestamp', sortable: true},
{header: "Instance", width: 120, dataIndex: 'olt', sortable: true},
{header: "DL", width: 50, dataIndex: 'dl', sortable: true}
], ...

fay
9 Mar 2011, 3:25 AM
See: http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.ColumnModel&member=setColumnHeader



grid.getColumnModel().setColumnHeader(2, 'Inst');

dusoo
9 Mar 2011, 3:32 AM
thanks a lot

Komal Vaswani
15 Jun 2011, 11:45 PM
Hi,
I am trying to do the same but its not working in IE9 browser. any idea? :(
Thanks,
Komal

aacoro
16 Jun 2011, 1:34 AM
Hi,
I am trying to do the same but its not working in IE9 browser. any idea? :(
Thanks,
Komal

Did you tried this in the newest 3 version? Quote from the blog :
Ext JS 3.4, which brings IE9 support to Ext JS 3.x;

Komal Vaswani
16 Jun 2011, 2:06 AM
yes I have tried using extjs 3.2 as well as 3.4 but still couldn't get the result in IE 9 browser. Its giving the error "Unable to get value of the property 'getColumnModel': object is null or undefined "

skirtle
17 Jun 2011, 8:00 AM
On the face of it that error message doesn't sound like it should be browser-specific. Does your code work in other browsers, or is IE 9 the only browser you've tried? My first guess would just be that grid, or whatever you've called it, is null or undefined and is not actually pointing to your grid component. Could you post a simple test case that exhibits the problem?

abhijit roy
31 Jan 2012, 11:26 PM
thanks a lot

chandan.behura
25 Jul 2012, 12:21 AM
<script type="text/javascript">
function start() {

gridPanel = Ext.create('Ext.grid.Panel', {
title : 'UDM',
//store : udmStore,
collapsible : true,
columns : getColumns(),
height : 200,
width : 400,
selType : 'cellmodel',


renderTo : Ext.getBody()
});

gridPanel.center();


}
colHeader=['Subject','StudName','StudRoll'];
function getColumns(){

var colGrid=new Array();
for ( var i= 0; i < colHeader.length; i++) {
header=colHeader[i];
colGrid.push('header:'+header);
}
}
Ext.onReady(start);
</script>