ExtJS4 存储代理 url 覆盖
我试图通过更改代理 url(实际端点而不是参数)来重用商店。是否可以使用以下语法覆盖商店实例的代理 URL:
{
...some view config ...
store: Ext.create('MyApp.store.MyTasks',{proxy:{url:'task/my.json'}}),
}
如果代理已在商店定义中明确定义?
编辑:AbstractStore源代码按以下方式设置代理
if (Ext.isString(proxy)) {
proxy = {
type: proxy
};
}
解决方案:store.getProxy().url = 'task/myMethod.json';
I am trying to reuse a store by altering proxy url (actual endpoint rather than params). Is it possible to override proxy URL for a store instance wih the following syntax:
{
...some view config ...
store: Ext.create('MyApp.store.MyTasks',{proxy:{url:'task/my.json'}}),
}
if proxy is already well defined on the Store definition?
EDIT: AbstractStore source code sets proxy the following way
if (Ext.isString(proxy)) {
proxy = {
type: proxy
};
}
SOLUTION : store.getProxy().url = 'task/myMethod.json';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
http://www.sencha.com /forum/showthread.php?149809-通过更改代理 URL 重用存储
http://www.sencha.com/forum/showthread.php?149809-Reusing-Store-by-changing-Proxy-URL
创建商店时不能单独覆盖代理的 url。您必须通过完整的代理。这是因为,库整体替换了代理!所以,你可以做的是:
现在另一种可能性是,在拥有 store 实例后更改终点。如果您需要从不同的端点加载存储,可以使用 load 方法。
因为,在您的情况下,您正在尝试重新使用商店,因此您可以传递整个代理。您的商店的 (MyApp.store.MyTasks) 构造函数应该能够处理新配置并将其应用到商店...这是一个示例:
You cannot override the url of a proxy alone when creating a store. You will have to pass a complete proxy. This is because, the library replaces the proxy as a whole! So, what you can do is:
Now another possibility is, changing the end point after you have the instance of store. If you need to load the store from a different endpoint, you can make use of the load method.
Since, in your case you are trying to re-use a store, you can pass the whole proxy. Your store's (MyApp.store.MyTasks) constructor should be capable of handling the new config and applying it to the store... Here is an example:
使用store.setProxy()方法。 链接:
Use the
store.setProxy()
method. Link here:我有一个 BaseStore,用于存储默认设置。
I have a BaseStore which I use to store default settings.