Reputation: 5370
I have the following columns that will always be in my grid.
columns:[
{
text:"Format",
dataIndex:'Format',
flex:1,
sortable:true
},
{
text:"Pending",
dataIndex:'Pending',
flex:1,
sortable:true
},
myExtraFields
// I have some extra columns i need to add here.
]
below pending. I will have list of other fields that change via serverside conditions. How can i set up a javascript variable that can hold multiple columns and how would i then add that to the grid.
** edit **
See where myExtraFields is. I would like to add the additional columns there. This variable will sit on my html page. The variable will contain multiple columns
Upvotes: 0
Views: 118
Reputation: 4421
You can make your column array dynamically, after your store has loaded you can go check which columns you'll have to make. Then you can call your grid.reconfigure() function to load your new columns into the grid.
Example:
var fixedColumns = [
{
text:"Format",
dataIndex:'Format',
flex:1,
sortable:true
},
{
text:"Pending",
dataIndex:'Pending',
flex:1,
sortable:true
}];
var variableColumns = [] //Generated by looking at your record
var columns = fixedColumns.concat(variableColumns);
grid.reconfigure(columns);
Upvotes: 1