存储装货单

时间:2012-08-28 11:22:17

标签: extjs extjs4 extjs-mvc

我在这里的App.js代码:

Ext.Loader.setConfig({
    enabled: true
});

Ext.application({
    name: 'KP',
    appFolder: 'scripts/app',

    controllers: [
        'MainSearch', 'List'
    ],

    launch: function () {
        Ext.create('Ext.container.Viewport', {
            items: {
                xtype: 'searchdata'
            }
        });
    }
});

问题是: 我有模型('列表'),存储('列表'),视图('列表')和控制器('列表') - 我的网格所有这一切。在商店('List')我调用了服务,它给了我一些数据。

我想在“MainSearch”表单后查看我的网格。所以,我首先打电话给“MainSearch”。 (在App.js中)。但是,在我的浏览器中显示“MainSearch”表单之前,调用了“List”中的服务。我不明白为什么会这样。 (当'List'控制器未包含在App.js中时 - 一切正常)

“List”的'Store'代码:

Ext.define('KP.store.List', {

    extend: 'Ext.data.Store',
    model: 'KP.model.List',          

    autoLoad: true,

    pageSize: 20,
    autoLoad: { start: 0, limit: 20 },


    autoSync: true,
    proxy: {
        type: 'ajax',
        limitParam: 'size',
        startParam: undefined,
        api: {

        read: '/adres/listls'
        },
        reader: {
            type: 'json',
            root: 'data',
            successProperty: 'success',
            totalProperty: 'total'
        }     
    }

});

'列表'控制器代码:

Ext.define('KP.controller.List', {

    extend: 'Ext.app.Controller',

    views: ['personAccount.List'],
    models: ['List'],
    stores: ['List'],

    init: function () {
        this.control({
            'list button[action=close]': {
                click: this.closeClick
            }
        });
    },

    //закрытие формы
    closeClick: function (button) {
        var win = button.up('window');
        win.close();
    }

}); 

我的列表查看代码:

Ext.define('KP.view.personAccount.List', {
    extend: 'Ext.window.Window',
    alias: 'widget.list',

    autoScroll: true,
    modal: false,
    plain: false,
    autoShow: true,
    layout: {
        type: 'fit'
    },

    initComponent: function () {
        var me = this;
        Ext.applyIf(me, {

            items: [
                            {
                                xtype: 'gridpanel',
                                store: 'List',

                                forceFit: true,
                                columns: [
                                            ....
                                       ],

                                dockedItems: [
                                              {
                                                  xtype: 'pagingtoolbar',
                                                  store: 'List',
                                                  dock: 'bottom',                                                     
                                                  displayInfo: true
                                              }

                                            ]
                            }

                    ]
        });



        me.callParent(arguments);
    }

});

非常感谢!

1 个答案:

答案 0 :(得分:2)

您需要做的是在商店中停用autoLoad。这种方式存储将被初始化,但它不会调用您的服务来获取数据。稍后,您将在网格的store.load()处理程序中调用afterrender