PDA

View Full Version : How i will get the value in column header through function in gridPanel



chandan.behura
25 Jul 2012, 12:28 AM
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);


please help me
regards chandan,

scottmartin
25 Jul 2012, 5:21 PM
See if this is what you are looking for:



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'change'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "change":100 },
{ 'name': 'Bart', "email":"bart@simpsons.com", "change":-20 },
{ 'name': 'Homer', "email":"home@simpsons.com", "change":23 },
{ 'name': 'Marge', "email":"marge@simpsons.com", "change":-11 }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

var grid = Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Change', dataIndex: 'change' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});

var columns = [{
dataIndex: 'company',
text: 'Company',
flex: 1
}];

Ext.create('Ext.Button', {
text: 'Click me',
renderTo: Ext.getBody(),
handler: function() {
grid.headerCt.add(columns);
grid.view.refresh();
}
});


Scott.

chandan.behura
25 Jul 2012, 9:08 PM
i got that solution....bellow is the solution but......
please try to help me in my another thread i.e i have given the link

http://www.sencha.com/forum/showthread.php?232789-Mail-ChatBox-Creation-in-extJS&p=861101&mode=threaded#post861101

var gridPanel = Ext.create('Ext.grid.Panel', {
title: 'Employees',
columns: getColumns(),
height: 200,
width: 500,
renderTo: Ext.getBody()
});
gridPanel.center();
}

var columnsIndex = ['empID','empName','email','sal'];
var columnsHeader = ['Employee ID','Employee Name','Email','Salary'];
var columnsSortable = [true,false,false,true];

function getColumns()
{
var gridColumns = new Array();
for(var i=0;i<columnsIndex.length;i++)
{
gridColumns[i] = {
header : columnsHeader[i],
dataIndex : columnsIndex[i],
sortable : columnsSortable[i]
};
}
return gridColumns;
}