【问题标题】:How to update store form in extjs4如何在 extjs4 中更新商店表单
【发布时间】:2013-04-20 12:06:23
【问题描述】:

我尝试迁移到 extjs4,但 'migration pack' return 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)
});

有什么想法吗?

【问题讨论】:

    标签: extjs extjs4 migration store


    【解决方案1】:

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

    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)
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-16
      • 2015-05-29
      • 2013-01-22
      • 2011-10-14
      • 2016-02-06
      • 2012-09-24
      • 1970-01-01
      • 2018-06-29
      相关资源
      最近更新 更多