tft
tft

Reputation: 1

why I can't use short name of store in ExtJs?

I use ExtJs 6.0.0 & Sencha Cmd 6.0.2 and use MVC architecture, I have a simple App for test generated by Sencha Cmd like below:

// MyApp/store/Personnel.js

Ext.define('MyApp.store.Personnel', {
  extend: 'Ext.data.Store',

  alias: 'store.personnel',


  fields: [
    'name', 'email', 'phone'
  ],

  data: {
    items: [{
      name: 'Jean Luc',
      email: "[email protected]",
      phone: "555-111-1111"
    }]
  },

  proxy: {
    type: 'memory',
    reader: {
      type: 'json',
      rootProperty: 'items'
    }
  }
});

// MyApp/app/view/main/List.js

Ext.define('MyApp.view.main.List', {
  extend: 'Ext.grid.Panel',
  xtype: 'mainlist',

  requires: [
    'MyApp.store.Personnel'
  ],

  title: 'Personnel',

  store: 'Personnel',
  //store: {
  //    type: 'personnel'
  //},

  columns: [{
    text: 'Name',
    dataIndex: 'name'
  }, {
    text: 'Email',
    dataIndex: 'email',
    flex: 1
  }, {
    text: 'Phone',
    dataIndex: 'phone',
    flex: 1
  }],

  listeners: {
    select: 'onItemSelected'
  }
});

// MyApp/app/Application.js

Ext.define('MyApp.Application', {
    extend: 'Ext.app.Application',
    
    name: 'MyApp',

    stores: [
        // TODO: add global / shared stores here
        'Personnel'
    ]  
});

It is, I want use short name of the Personnel store(only Classname with out Namespace) in the view of List, but it doesn't work. But in the Ticket App (the example of Sencha official recommend also in the SDK) it use like this and work perfectly, why mine doesn't work correctly? The app.json looked like same.

Upvotes: 0

Views: 304

Answers (1)

Evan Trimboli
Evan Trimboli

Reputation: 30092

store: 'foo' means a store with the id foo. That store must already have an instance created.

You should use the type syntax you have commented out there.

Upvotes: 0

Related Questions