简体   繁体   English

EXTJS 5我可​​以在视图模型的store属性中有一个树存储吗?

[英]EXTJS 5 Can I have a tree store in stores property of view model?

I have this simple mvvm example: https://fiddle.sencha.com/#fiddle/j8m 我有一个简单的mvvm示例: https ://fiddle.sencha.com/#fiddle/j8m

When I console.log the viewModel from the controller, stores appear in the data attribute, calling viewModel.getStores() returns me null. 当我从控制器进行console.log viewModel的存储时,存储出现在data属性中,调用viewModel.getStores()返回null。 I don't get it :/... 我不明白:/ ...

Here is the same code as in the fiddle: 这与小提琴中的代码相同:

Ext.define('MainViewModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.mainviewmodel',

    stores: {
        todoAccountsStore: {
            type: 'tree'
        },
        skipAccountsStore: {
            type: 'tree'
        }
    }
});

Ext.define('MainViewController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.mainviewcontroller',

    init: function() {
        console.log(this.getViewModel());
    }
});

Ext.define('MainView', {
    extend: 'Ext.panel.Panel',
    xtype: 'view-main',

    controller: 'mainviewcontroller',

    viewModel: {
        type: 'mainviewmodel'
    }
});

var test = Ext.create('MainView', {
    renderTo: Ext.getBody()
});

To retrieve your stores, you can use the following code within your controller: 要检索商店,您可以在控制器中使用以下代码:

var viewModel = this.getViewModel();
var todo = viewModel.getStore('todoAccountsStore');
var skip = viewModel.getStore('skipAccountsStore');

Based on this thread they state that the getStores method was intended to be private. 他们基于此线程声明getStores方法旨在为私有。 I presume the docs have still has not been updated to represent this. 我认为文档仍未更新以表示这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM