重庆熊猫 Loading

ExtJS-数据处理-获得Store对象实例

更新记录
2022年7月17日 发布。
2022年7月6日 从笔记迁移到博客。

ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.html

获得Store对象实例

实例:使用StoreManager获得数据存储

使用StoreManager类的lookup方法

Ext.data.StoreManager.lookup('PandaApp.store.Store');

可以从应用程序中的任何位置获得数据存储实例
注意:需要指定数据存储的storeId参数
注意:当Store被Controller实例化时,storeId将被Store的名称覆盖
这个方法还有一个快捷方法别名:

Ext.getStore('StoreName');

注意:需要在Application.js文件的Store配置项中添加已经定义的Store的名称

stores: [
	'Users'
],

实例:

Ext.create('Ext.data.Store', {
    model: 'Employee',
    storeId: 'mystore',
    proxy: {
        type: 'rest',
        url: '/employee',
        reader: {
            type: 'json',
            rootProperty: 'data'
        }
    }
});
//使用StoreManager获得数据存储实例,注意:这里用的StoreId
Ext.data.StoreManager.lookup('myStore');

实例:从ViewModel中获得Store-使用getStore方法

可以通过Ext.app.ViewModel的getStore方法获得Store
提示:getStore也可以在ViewConroller中使用
提示:getStore也可以在View中使用

var myStore = this.getViewModel().getStore('myStore')

实例:让指定的Store进行同步数据

Ext.getStore('Users').sync();
posted @ 2022-07-17 07:59  重庆熊猫  阅读(617)  评论(0编辑  收藏  举报