PDA

View Full Version : Dynamic columns in grid



Vamshi Barana
20 Jun 2013, 1:02 AM
Hi,

Please do help me in displaying the grid with incrementing the columns depending upon the data from store in extjs 3.4




Thanks,
Vamshi

Colin Alworth
20 Jun 2013, 5:12 AM
Moved to Ext JS 3 Help forum.

Vamshi Barana
20 Jun 2013, 5:39 AM
Hi,

Sorry,I dint the solution.




Thanks,
Vamshi

Vamshi Barana
20 Jun 2013, 5:41 AM
Hi,

Sorry ,I dint get the solution...




Thanks,
Vamshi

gokulpotluri
21 Jun 2013, 3:00 AM
Hi,

First store the fields and the headers in an array and create a separate array for column model.
Now use for loop to create column model array and add it to the grid.

fieldArray, headerArray and columnModelArray

for (var i=0;i<headerArray.length;i++)
{
columnModelArray.push(
new Ext.grid.Column({
header : headerArray[i],
sortable : true,
dataIndex : fieldArray[i]
})
);
}

now add this columnModelArray directly to the grid. but please note that data in fieldArray, headerArray should be in same order and same length.

Vamshi Barana
24 Jun 2013, 1:36 AM
Hi,

Thanks alot for the solution.:):):) I am getting the incremented grid but stucked up with dataIndex nd showing it in grid.



Thanks,
Vamshi

Vamshi Barana
24 Jun 2013, 2:52 AM
Hi,

Can I have any example of it.

Vamshi Barana
3 Jul 2013, 10:10 PM
Hi,

Is it possible to give data index for row.I need to display data in row wise....Plzz anybody help me

Vamshi Barana
3 Jul 2013, 11:31 PM
Hi,
Help me in displaying the data in below format in a grid where columns should incremented depending upon data .I am not getting how to give dataIndex for row.





13:55/13:30
14:30
16:55




Bangalore
Tumkur
Sira
Chitradurga
Hubli
Pune


12:42/12:45
14:00
15:10
16:58


























and below is my code,


columnModelArray=[
//new Ext.grid.RowNumberer(),
{hidden:true,
renderer:function(){

// alert(routeGridStore.getCount());
var countlength=routeGridStore.getCount()/2;
//alert(countlength);

for (var i=0;i<countlength;i++)
{

fieldArray=routeGridStore.getAt(i).get('locationName');
//alert('fieldArray[i]'+fieldArray+i);
columnModelArray.push(
new Ext.grid.Column({

header :fieldArray
sortable : true,
autoHeight : true,
width:40,
height:90,
dataIndex:fieldArray
//sortable : true,
})

);





}

}



}
]


//main grid for displaying the followMe details
var routeViewGrid=new Ext.grid.GridPanel
({
id:'routeViewGrid',
autoScroll:true,
viewConfig: {forceFit: false},
anchor:'100% 100%',
store:routeGridStore,
autoHeight : true,
stripeRows : true,
loadMask: true,
border:false,
columns: columnModelArray









}) ;