Frage

I am using MVC architecture to load data into a list, and displaying it on screen. Upon running the app I get the following error

[WARN][test.view.list#applyStore] The specified Store cannot be found

I tried following the instructions given here, but it gave me error:

file not found at null/view/list.js null/store/list1store.js null/model/list1modeljs

The root directory of application is "test".

List model file:

Ext.define('test.model.list1model', {
extend: 'Ext.data.Model',
config: {
    fields: [
        {name: 'firstName', type: 'string'},
        {name: 'lastName',  type: 'string'},
        {name: 'age',       type: 'int'},
        {name: 'eyeColor',  type: 'string'}
        ]
    }
});

List store file:

Ext.define("test.store.list1store", {
extend:'Ext.data.Store',
requires:['test.model.list1model'],
config:{
  model: "test.store.list1model",
data : [
    {firstName: "Ed",    lastName: "Spencer"},
    {firstName: "Tommy", lastName: "Maintz"},
    {firstName: "Aaron", lastName: "Conran"},
    {firstName: "Jamie", lastName: "Avins"}
]
}
});

List view file:

Ext.define("test.view.list", {
extend:'Ext.List',
requires:['test.store.list1store'],
config:{fullscreen: true,
store: 'test.store.list1store',
itemTpl: "{lastName}, {firstName}"
}
});

app.js:

Ext.application({
requires: [
'Ext.dataview.List',
'Ext.Panel',
 'Ext.Spacer',
  'test.view.list',
  'Ext.List',
  'test.model.list1model',
  'test.store.list1store'
],
launch : function(){
    list1 =Ext.create('test.view.list');
    Ext.create('Ext.Container',{
      id:'contain',

      fullscreen:true,
      items:[
    list1,
      ]
    })
  }
});
War es hilfreich?

Lösung

You only defined a Store, but did not instantiate it. Try the following:

Ext.define("test.view.list", {
    extend:'Ext.List',
    requires:['test.store.list1store'],
    fullscreen: true,

    constructor : function() {
        this.callParent();
        this.setStore(Ext.create("test.store.list1store"));
    },

    config: {
        fullscreen: true,
        itemTpl: "{lastName}, {firstName}"
    }

});

PS: correct your model in the store to this: model: "test.model.list1model"

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top