Vitali Zakharoff
Vitali Zakharoff

Reputation: 353

extJS gridpanel loading datafrom database

I found this extjs script that create a empty gridpanel:

    var gridz = new Ext.grid.GridPanel({
   // store: dstore,
        columns: [
        {id:'id', header: "Id", width: 60,  sortable: true, dataIndex: 'id'},
        {id: 'data', header: "Data", width: 200, sortable: true, dataIndex: 'data'}
        ],
        stripeRows: true,
        autoExpandColumn: 'data',
        height:350,
        width: 500,
        title:'Demo Data'
    });

now is question: I have table called answers, how i can put my data from database intro this grid?

Upvotes: 1

Views: 1364

Answers (1)

Craig
Craig

Reputation: 2193

The bit that you've commented out, 'store', is responsible for storing your data. You may wish to use a JsonStore, for example, which makes a request to your server to get the answers in JSON format. You then create a column model (that's the 'columns' property in your example') for the grid that knows which fields in your store map to columns in your grid.

There are some tutorials here that it'd be worth you reading through: http://www.sencha.com/learn/Tutorials#Grids. They may be for older versions of ExtJS than you're using but the principle is still the same.

Upvotes: 2

Related Questions