使用Ext JS的MVC架构中的store.load()的动态代理URL [英] Dynamic Proxy URL for store.load() in MVC architecture with Ext JS

查看:123
本文介绍了使用Ext JS的MVC架构中的store.load()的动态代理URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在(!)加载之前更改商店的代理。在这种情况下的具体问题是我找不到正确的时机,何时加载。



详细说明:



我已经通过创建一个视图,控制器,模型和由EXTJS4架构定义的存储创建了一个MVC模型。视图是一个网格面板。它在自己的定义语句中定义了商店:

  Ext.define('P.view.MyView',{
扩展:'Ext.grid.Panel',
别名:'widget.MyView',
...
store:'MyStore',
...

当我使用autoload:true加载商店时,一切正常,但当然代理是静态的,如代码中定义的那样,当我不使用autoload并尝试设置extraParams,并将存储加载到我的视图的initComponent中,如:

  initComponent:function(){
...
this.store.load();
....

我收到一个错误:对象MyStore没有方法'load'。



我应该怎么做?

解决方案

当您致电 this.store在initComponent中的.load()存储没有初始化,属性 this.store 是cal的时刻的字符串你必须在你的窗口小部件的父 initComponent (存储初始化发生的地方)被调用之后调用加载:

  initComponent:function(){
...
this.callParent(arguments);
this.store.load();
....


I want to change the proxy of a store before (!) it is loaded. The specific problem in this case is that I do not find the right moment, when to load.

In detail:

I have created a MVC-model by creating a view, a controller, a model, and a store as defined by EXTJS4 architecture. The view is a grid panel. It defines the store within its own define statement:

Ext.define('P.view.MyView' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.MyView',
    ...
    store: 'MyStore',
    ...
}

When I load the store with "autoload:true" everything works fine, but of course the proxy is then static as defined in the code. When I do not use "autoload" and try to set "extraParams" and the load the store in the "initComponent" of my view like:

initComponent: function() {
    ...
    this.store.load();    
    ....

I get an error: Object "MyStore" has no method 'load'.

How should I do it?

解决方案

When you call this.store.load() in initComponent the store is not initialized yet. The property this.store is string at the moment of calling. You have to call for loading after your widget's parent initComponent (where the store initialization is happening) was called:

initComponent: function() {
    ...
    this.callParent(arguments);
    this.store.load();    
    ....

这篇关于使用Ext JS的MVC架构中的store.load()的动态代理URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆