簡體   English   中英

Extjs無法從商店加載數據

[英]Extjs not loading data from store

我正在學習ExtJS的,並試圖創建以下簡單的應用程序指南。

我的app.js文件:

sstore = new Ext.data.Store({
    autoLoad: true,
    fields: ['firstName', 'lastName', 'educationId', 'townId'],
    proxy: {
        type: "ajax",
        url: "data",
        reader: {
            type:"json",
            root: "users"
        }
    }
});


Ext.application({
    name: 'Application',
    autoCreateViewport: true,
    controllers: ['MainController']
});

Viewport.js

Ext.define('Application.view.Viewport', {
    extend: 'Ext.container.Viewport',
    layout: { type: "vbox", align: 'stretch' },

    items :  [{
        xtype: 'mainList',
        autoScroll: true
    }]
});

List.js

Ext.define('Application.view.List', {
    extend: 'Ext.grid.Panel',
    alias : 'widget.mainList',
    title : 'Users',

    store: sstore,     // ***** LOOK HERE PLEASE *****
    //store: 'Users',

    columns: [
        { header: 'Имя',  dataIndex: 'firstName' },
        { header: 'Фамилия', dataIndex: 'lastName' },
        { header: 'Образование', dataIndex: 'educationId'},
        { header: 'Город', dataIndex: 'townId'}
    ]
});

商店( Users.js ):

Ext.define('Application.store.Users', {
    extend: 'Ext.data.Store',    
    storeId: 'usersStore',    
    //model: 'Application.model.User',    
    fields: ['firstName', 'lastName', 'educationId', 'townId'],    
    autoLoad: true,    
    proxy: {
        type: 'ajax',
        url: 'data',
        reader: {
            type: 'json',
            root: 'users'
        }
    },    
    onProxyLoad: function (aOperation) {
        console.log('From store');
        console.log(aOperation);
    }

});

當我改變了store: sstorestore: 'Users'在我List.js文件,它不會加載任何數據,但在app.js文件,它生活在sstore變量,創建存儲,它工作正常。

我嘗試了什么,但沒有幫助:

  • 使用內存代理,
  • 使用的store: Ext.data.StoreManager.lookup('usersStore'),
  • 后端數據沒問題(因為sstore工作正常)

我可以看到Users.js中的商店正在加載(因為onProxyLoad函數的控制台輸出)。

這是我在瀏覽器中看到的:

在此處輸入圖片說明

完整的js應用程序住在這里

我的查看文件在這里

我正在使用extJS 4.2

這真是愚蠢。 問題出在onProxyLoad函數中。 當我從商店應用中刪除它時,它按預期工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM