I was successfully able to load grid columns dynamically in ExtJs3.
However, I have failed to get it working in ExtJs4.
I can load the columns dynamically but I cannot get them to display in the grid.
When the store loads I build a Column Model, I then set the grids columns as this Column Model.
After setting the grids columns I tried calling the grid.doLayout() method and also grid.getView().refresh() method but the columns are never displayed.
Below is some example code:
store.on('load', function(st){
var columnModel = store.data.items;
grid.columns = columnModel;
grid.doLayout();
/**
* I also tried doing it this way
**/
//grid.getColumnModel().setConfig(columnModel);
//grid.getView().refresh();
});
The grids columns property seems to be getting set correctly but these columns are never displayed.
Just for further clarity the column model which I set as the grids columns property looks like this:
[{
header: 'Name',
dataIndex: 'empname'
},{
header: 'Address',
dataIndex: 'address'
},{
header: 'Department',
dataIndex: 'dept'
}]