PDA

View Full Version : Ext.data.Store & AjaxPro



Cypherpunk
28 Mar 2012, 7:39 AM
I'm trying to upgrade this store from Ext 2.x to Ext 4.x for an Ext.grid.Panel:

Old


Ext.namespace("Example.Project");

Example.Project.DataStore = function(id){

var proxy = new Ext.data.HttpProxy({
url: _ajaxUrl,
method:"POST",
headers:{"x-ajaxpro-method":"GetAllItems"}
});

var rdr = new Ext.data.JsonReader({id: "ItemId", root: "Items", totalProperty: "TotalUnPaged"},[
{name: 'ItemId'},
{name: 'UserId'},
{name: 'CreatedOn'},
{name: 'AvatarUrl'},
{name: 'DisplayName'},
{name: 'EmailAddress'}
]);

Example.Project.DataStore.superclass.constructor.call(this, {
remoteSort: true,
proxy: proxy,
reader: rdr
});

this.baseParams = {
id: id
};
};

Ext.extend(Example.Project.DataStore, Ext.data.Store, {
});

New

Ext.define('Example.Project.ArticleDataStore', {
extend: 'Ext.data.Store',
alias: 'widget.itemstore',
id: "DataStore",
remoteSort: true,

config: {
id: '-1'
},

constructor: function (config) {
this.initConfig(config);

this.callParent(arguments);
},

initComponent: function () {
var me = this;

Ext.define('Example.Project.data.Model', {
extend: 'Ext.data.Model',
fields: [
{name: 'ItemId'},
{name: 'UserId'},
{name: 'CreatedOn'},
{name: 'AvatarUrl'},
{name: 'DisplayName'},
{name: 'EmailAddress'}
]
});

me.model = 'Example.Project.data.Model';
me.autoLoad = true;
me.pageSize = 10;
me.proxy = {
type: 'ajax',
url: _ajaxUrl,
headers: { "x-ajaxpro-method": "GetAllItems" },
extraParams: {
id: this.id
},
reader: {
type: 'json',
root: 'Items',
idProperty: 'ItemId',
totalProperty: 'TotalUnPaged'
}
};
}
});

But I'm getting the following error message:
me.model is undefined


me.setProxy(me.proxy || me.model.getProxy());


Please help.

mitchellsimoens
28 Mar 2012, 8:58 AM
Only components have an initComponent method and Store doesn't extend Ext.Component. You will need to do that in the constructor.