views:

45

answers:

2

Hi, Is it possible to get every data from the server? for example, i want to get the columns items from the server Via Ajax/Proxy by sending json string? thanks

var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{id:'company',header: 'Company', width: 160, sortable: true, dataIndex: 'company'},
{header: 'Price', width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
{header: 'Change', width: 75, sortable: true, renderer: change, dataIndex: 'change'},
{header: '% Change', width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'},
{header: 'Last Updated', width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
stripeRows: true,
autoExpandColumn: 'company',
height: 350,
width: 600,
title: 'Array Grid',
stateful: true,
stateId: 'grid'
}); 
A: 

Yes you can.

you can get the whole code in your example generated by the server and eval'd on the client, or you can have for example the array of the columns returned as a JSON object, parsed by the client, and then use the created object as the "columns" config option in your code that created a grid.

Since JavaScript is interpreted and you can download text from the server you can do just about any trick like this.

ob1
A: 

Send your data through the "metaData" property. Therefore, the Store will fire an "metachange" event, and you can perform reconfigure on the grid with the following method:

grid.reconfigure(store, new Ext.grid.ColumnModel(metaData.columns));
CrazyEnigma
it's not metadata, make sure it's a capital "D": meta"D"ata
CrazyEnigma