PDA

View Full Version : problem with store in a grid



prassler
12 Mar 2013, 12:25 AM
Hi all,

I have a problem to create a grid in extjs 4.1.3
If I use the following code there is an "store is undefined" error on extjs-all-debug.js line 100539


Ext.define( 'MyApp.Model.Request', {
extend: 'Ext.data.Model',
fields: [
{"name":"id","type":"int"},
{"name":"type","type":"string"}
],
idProperty: 'id'
});
Ext.define('MyApp.Store.RequestData', {
extend: 'Ext.data.Store',
model: 'MyApp.Model.Request',
data : [
{id: 1, type: 'Spencer'},
{id: 2, type: 'Maintz'},
{id: 3, type: 'Conran'},
{id: 4, type: 'Avins'}
]
});
Ext.define('MyApp.View.RequestList' ,{
extend: 'Ext.grid.Panel',
store: 'MyApp.Store.RequestData',
width: 200,
columns: [
{"text":"ID","width":100,"dataIndex":"id"},
{"text":"Type","width":100,"dataIndex":"type"}
]
});
Ext.define('MyApp.Controller.RequestHandler', {
extend: 'Ext.app.Controller',
models: ['MyApp.Model.Request'],
stores: ['MyApp.Store.RequestData'],
init: function() {
//console.log('Initialized Users! This happens before the Application launch function is called');
},
list: function( renderTo ) {
var grid = this.getView('MyApp.View.RequestList').create({
renderTo: renderTo
});
grid.focus();
}
});
Ext.application({
name: 'MyApp',
appFolder: 'MyApp',
controllers: [
'MyApp.Controller.RequestHandler'
],
requires : [
'MyApp.Controller.RequestHandler'
],
launch: function() {
var controller = this.getController( 'MyApp.Controller.RequestHandler' );
controller.list( '93b67ba52a348fc648c81240636f6dd9' );
}
});

I tested extjs version 4.1.1, but in this version the code works perfectly. http://jsfiddle.net/Hvevq/
Futher I tested version 4.2 RC it works too.

What is the failure in 4.1.3 ?

Thx for helping

mitchellsimoens
13 Mar 2013, 1:23 PM
It will go to the StoreManager and try to get an instance of it based on the storeId given to the store. The controller/application will use RequestData as the storeId for that store not MyApp.store.RequestData