0

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: "jeanluc.picard@enterprise.com",
      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.

tft
  • 1
  • 3
  • Try filling in that line in Application.js where it says to add the global/shared stores... – Robert Watkins Oct 18 '15 at 10:41
  • Sorry for that, It is there and should be there, I only had a mistake in the post above... – tft Oct 18 '15 at 11:20
  • What do you mean by 'it doesn't work'?Is there some errors? If you do not see the data in grid, try to remove items from data and place objects directly into the data array. Local data doesn't use the proxy. Your code should work without any store Id. – yorlin Oct 18 '15 at 14:00
  • Nothing errors, only without TreeNode or Grid content rendered. – tft Oct 18 '15 at 14:05
  • If I use complete store name(MyApp.model.Personnel) or storeId it works fine. – tft Oct 18 '15 at 14:07
  • @tft what returns getStore() method after the grid is rendered? – yorlin Oct 18 '15 at 14:35
  • @yorlin Sorry for the lated reply. It returned seemed like a Store instance with data(also a MODEL instance ) and id named it's short name. – tft Oct 19 '15 at 04:27
  • @yorlin AND there is a error when use short name in grid.view when open Chrome debug tool, it said **Uncaught TypeError: Cannot read property 'isBufferedStore' of undefined**, looks like the grid can't get store. – tft Oct 19 '15 at 04:34
  • @yorlin also a error said **Uncaught TypeError: Cannot read property 'getRoot' of undefined** when use `Ext.tree.Panel`. – tft Oct 19 '15 at 04:38
  • @tft I have created a fiddle and it works properly https://fiddle.sencha.com/#fiddle/vlo . I can assume 2 problems: 1) your store is placed in the wrong directory(not in the store folder of the app directory). 2) There is some problem due to versions difference between cmd and extjs. – yorlin Oct 19 '15 at 06:41
  • @yorlin Thank you very much, I will try other Extjs version. – tft Oct 19 '15 at 06:52

1 Answers1

0

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.

Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66
  • Maybe you are right, I had used a **storeId** with store definition, it worked fine. but I hadn't find anything else from Sencha official's examples with stores definition except somethings in my question, and it works fine, too. – tft Oct 18 '15 at 11:59