Showing posts with label How to change grid column header name in extjs. Show all posts
Showing posts with label How to change grid column header name in extjs. Show all posts

Thursday, 10 May 2012

How to change grid column header name in extjs



Suppose I have below grid. I want to change header 2 to  "Inst" from "Instance".

    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}
        ], ...

In extjs 3.x :

   Use the code like this
  grid.getColumnModel().setColumnHeader(2,'Inst');


In extjs 4.x :

   Use the code like this.
   grid.columns[1].setText('Inst');