gpt4 book ai didi

extjs - 应用程序启动时不应加载带有 autoload true 的存储

转载 作者:行者123 更新时间:2023-12-03 17:05:36 24 4
gpt4 key购买 nike

我有一个网格链接到一个带有 autoLoad: true 的商店.问题是存储在应用程序启动时加载,即使 View 是在稍后通过菜单访问时才创建的。

我已经在 Application.js 和 View 中引用了商店,但我没有明确说明商店和 View 。

我不知道如何实现仅在 View 需要时才加载商店。

  • 如果我设置 autoLoad: true ,商店在应用程序启动时加载。
  • 如果我设置 autoLoad: false ,商店根本没有被加载。

  • 我知道这是非常基本的,但到目前为止我被卡住了。

    以下是所有相关代码供引用:
    应用程序/商店/Owners.js
    Ext.define('Mb.store.Owners', {
    extend: 'Ext.data.Store',
    model: 'Mb.model.Owner',
    autoLoad: true,
    proxy: {
    ...
    });

    应用程序.js
    Ext.define('Mb.Application', {
    name: 'Mb',
    extend: 'Ext.app.Application',
    models: [
    'Owner'
    ],
    stores: [
    'Owners'
    ],
    ...

    应用程序/ View /Owners.js
    Ext.define('Mb.view.winbiz.Owners', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.test-gridPanel',
    store: 'winbiz.Owners',
    columns: [{
    ...

    View 在 Controller 中实例化:
    Ext.define('Mb.controller.Winbiz', {
    extend: 'Ext.app.Controller',
    views: [
    'Owners'
    ],
    init: function(){
    this.control({
    'menu #test': {click: this.onMenuTest},
    })
    },
    onMenuTest: function(){
    this.getController('Main').addToMainTab('test-gridPanel');
    },

    最佳答案

    您可以添加 render处理程序查看哪个将调用存储 load方法和禁用 autoLoad .

    示例监听器:

    Ext.define('Mb.view.winbiz.Owners', {
    extend: 'Ext.grid.Panel',
    [...],

    initComponent: function(){
    this.callParent();
    this.on('render', this.loadStore, this);
    },

    loadStore: function() {
    this.getStore().load();
    }
    });

    关于extjs - 应用程序启动时不应加载带有 autoload true 的存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19588780/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com