0

我尝试迁移到 extjs4,但“迁移包”返回 massege '[BREAKING][4.0][Ext.data.Store]:指定了一个商店,但没有配置模型、url 或字段。有关正确设置数据组件的详细信息,请参阅 Ext.data.Store 的标题文档。这是在兼容层中无法解决的重大更改!

我的商店看起来像

    Ext.namespace('App.data');

Ext.define('App.data.Store', {
    extend: 'Ext.data.Store',
    constructor: function(config) {
        this.addEvents(
            'beforeupdate'
        );

        this.callParent(this, config);
        this.app_modFlag = false;
        this.app_Updates = null;

        this.on('load', function(store) {store.app_modFlag = false});
        this.on('update', function(store) {store.app_modFlag = true});
        this.on('add', function(store) {store.app_modFlag = true});
        this.on('clear', function(store) {store.app_modFlag = true});
        this.on('remove', function(store) {store.app_modFlag = true});
    },
    remoteSort: true,

    /**
        If true, object will automatically choose sort or local sort methods
            depending of number of data pages
    */
    autoChooseSortType: true,

    /* Overriden methods */

    load: function(options) {
        options = options || {};

        if (options.params && options.params.gridState && !isNaN(options.params.gridState.pageNo * options.params.gridState.pageSize)) {
            options.params.start = options.params.gridState.pageNo * options.params.gridState.pageSize;
            options.params.limit = options.params.gridState.pageSize;
        }
        if (options.params && options.params.gridState && options.params.gridState.sortField) {
            options.params.sort = options.params.gridState.sortField;
            options.params.dir = options.params.gridState.descendingOrder ? 'DESC' : 'ASC';
        }

        return App.data.Store.superclass.load.call(this, options);
    },


    loadRecords: function(o, options, success) {
        if (this.autoChooseSortType && this.reader && !isNaN(this.reader.pageNumber) && this.reader.pageNumber > 0) {
            this.remoteSort = this.reader.pageNumber > 1;
        }
        App.data.Store.superclass.loadRecords.call(this, o, options, success);
    },

    /**
        Returns number of pages current server storage
        Requires using of PagedListReader class as reader
    */
    getPageNumber: function() {
        return this.reader && !isNaN(this.reader.pageNumber) ? this.reader.pageNumber : Number.NaN;
    },..........
  .....................................................................................................................................................

Ext.define('AppRecord', {        extend: 'Ext.data.Model',
    fields: [
        {name: 'appId'},
        {name: 'name', sortType: Ext.data.SortTypes.asUCString},
        {name: 'clientName', sortType: Ext.data.SortTypes.asUCString},
        {name: 'creationTime', type: 'date'},
        {name: 'stage', type: 'int'},
        {name: 'type'}
    ]
});


var store = new App.data.Store({
    proxy: new App.data.DwrProxy({
        invoker: function(params, arg, cb) {
            if (params.searchParams != null) {
                AppManager.search(params.searchParams, params.gridState, cb);
            } else if (params.removeId != null) {
                AppManager.removeApp(params.removeId, params.gridState, cb);
            } else {
                AppManager.getAppList(params.gridState, null, cb);
            }
        }
    }),

    reader: new App.data.PagedListReader({
        id: 'appId'
    }, AppRecord),
    sorters: App.util.makeSortInfo(App.appManager.gridState)
});

任何想法?

4

1 回答 1

0

您忘记将模型分配给您的商店:

var store = new App.data.Store({
    model: "AppRecord",//you need this added
    proxy: new App.data.DwrProxy({
        invoker: function(params, arg, cb) {
            if (params.searchParams != null) {
                AppManager.search(params.searchParams, params.gridState, cb);
            } else if (params.removeId != null) {
                AppManager.removeApp(params.removeId, params.gridState, cb);
            } else {
                AppManager.getAppList(params.gridState, null, cb);
            }
        }
    }),

    reader: new App.data.PagedListReader({
        id: 'appId'
    }, AppRecord),
    sorters: App.util.makeSortInfo(App.appManager.gridState)
});
于 2013-04-26T14:08:28.507 回答