PDA

View Full Version : Create a ColumnModel based on JSon Store



jbpd
6 May 2009, 9:31 PM
I have the following code:

// create the data store
var store = new Ext.data.JsonStore({
url: 'dataLoader.php?table=login',
fields: [
{name: 'CustID', type: 'int'},
'CustID', 'TimeIn', 'Location'
]
});

var GridColModel = new Ext.grid.ColumnModel([
{id:'CustID',header: "Customer ID", width: 160, sortable: true, locked:false, dataIndex: 'CustID'},
{header: "Time In", width: 75, sortable: true, dataIndex: 'TimeIn'},
{header: "Location", width: 75, sortable: true, dataIndex: 'Location'}
]);

I will be having multiple table's data loaded into the grid, which could have 2 columns or it could have 13+ columns....

I don't know how I can make it work, so that depending on what I load, it will always be able to display.

I've looked at all the dynamic Column stuff and can't figure out a plain and simple way to do it. I'm surprised there isn't a way to simply say...load the columns from the JSon store...such as loading a dataGridView from a DataTable in C#...where it creates the columns for you.

I'm a beginner and if this has already been posted somewhere else or answered, I apologize and would like the link so that I can figure it out. Thanks, Jeremy Brown