View Full Version : problem with GridPanel

5 Dec 2011, 8:40 AM
Hi all,
I've a little bit problem with this code (I'm using extjs 3.2.1) :

var groupStore = new Ext.data.JsonStore({
baseParams: '',
method: 'POST',
url: ';',
root: 'results',
fields: [ 'gid', 'groupname', 'accesslevel', 'groupdesc' ],

var groupGrid = new Ext.grid.GridPanel({
store: groupStore,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
loadMask: true,
border: false,
autoload: true,

columns: [
new Ext.grid.RowNumberer(),
{ id: 'gid', header: "GID", dataIndex: 'gid', width: 25 },
{ header: "Name", dataIndex: 'groupname'/*, width: '40%'*/ },
{ header: "AccessLevel", dataIndex: 'accesslevel', /*width: '60%',*/ menuDisabled: true },
{ id: 'description-col', header: "Description", dataIndex: 'groupdesc', /*width: '60%',*/ menuDisabled: true }
defaults: {
sortable: true,
menuDisabled: false
viewConfig: {

I think the problem is that I don't display any data because I don't call groupGrid.load() . But other examples I saw the groupGrid.load() called first of groupGrid in onReady() method i.e.:

var groupGrid = new Ext.grid.GridPanel({

but I have to call groupStore.load() inside groupGrid = new Ext.grid.GridPanel({.. HERE..});

how can i do ?

5 Dec 2011, 12:54 PM
autoLoad is intended for this:

autoLoad (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Panel-cfg-autoLoad) : Object/String (http://docs.sencha.com/ext-js/3-4/#!/api/String)/Function (http://docs.sencha.com/ext-js/3-4/#!/api/Function)
A valid url spec according to the Updater Ext.Updater.update (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Updater-event-update) method. If autoLoad is not null, the panel will attempt to load its contents immediately upon render.
The URL will become the default URL for this panel's body (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Panel-property-body) element, so it may be refreshed at any time.

So basically, you load content of another url inside the panel, note that autoLoad is inherited...

If what you want is to set store autoLoad then move that config option to the store.

You can call store.load(); before or after instantiate the gridPanel, but if you set autoLoad: true on store you don't need to call explicitly store.load...

6 Dec 2011, 7:29 AM
I've solved. there were two problems :
1)the "method" it were "GET" Altough i've setted to POST in the userStore, I've setted it after userStore definition.

var userStore = new Ext.data.JsonStore({
baseParams: '',
url: 'http://blabalbla.......',
totalProperty: 'totalCount',
root: 'results',
id: 'uid',
fields: [ 'uid', 'username', 'gid', 'email', 'password' ]
userStore.proxy.conn.method = 'POST'; // <--------

2) I had to add the listener function "render" in order to "load" the data.