-
15 Jun 2012 4:23 AM #1
Answered: Updating (seting) column herder
Answered: Updating (seting) column herder
I have tried to set column header with these codes but they didn't work. I couldn't figure out what to do.
PHP Code:this.headerCt.setColumnHeader(2,"Surname");
grid.getColumnModel().setColumnHeader(2,"Surname");
-
Best Answer Posted by redraid
You can get column by itemId and rename header text:
PHP Code:Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ itemId: 'col1', header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody(),
tbar: [{
text: 'Rename 1st column',
handler: function (btn) {
var grid = btn.up('grid'),
col = grid.down('#col1');
console.log(grid, col);
col.setText('Renamed');
}
}]
});
-
15 Jun 2012 4:47 AM #2
You can get column by itemId and rename header text:
PHP Code:Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ itemId: 'col1', header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody(),
tbar: [{
text: 'Rename 1st column',
handler: function (btn) {
var grid = btn.up('grid'),
col = grid.down('#col1');
console.log(grid, col);
col.setText('Renamed');
}
}]
});


Reply With Quote