[英]Accessing Ext Designer JsonStore from another file
I want to access an JsonStore created from the ext designer from another panels user js file. 我想从另一个面板用户js文件访问从ext设计器创建的JsonStore。 The file store file generated from the designer looks like this 从设计器生成的文件存储文件如下所示
myJsonStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
CoaJsonStore.superclass.constructor.call(this, Ext.apply({
storeId: 'myJsonStore',
url: '/server.json',
restful: true,
autoLoad: true,
autoSave: false,
fields: [
{
name: 'id'
},
{
name: 'code'
},
{
name: 'name'
}
]
}, cfg));
}
});
new myJsonStore();
what i am doing right now is using a hidden combo and assign the store to the combo, this allows me to access it via autoRef (with. combo.getStore(), it gives me an object type of Store). 我现在正在执行的操作是使用隐藏的组合,并将存储分配给组合,这使我可以通过autoRef(使用combo.getStore(),它为我提供对象类型)来访问它。 Ideally i want to be able to do it without the hidden combo. 理想情况下,我希望能够在没有隐藏组合的情况下进行操作。
i have tried referring to it with storeId, but it doesn't work, if i log the storeId to the console this is what i get. 我试图用storeId引用它,但是它不起作用,如果我将storeId登录到控制台,这就是我得到的。
function (cfg) {
cfg = cfg || {};
CoaJsonStore.superclass.constructor.call(this, Ext.apply({
storeId: 'myJsonStore',
url: '/coas.json',
restful: true,
........
so i was just wondering whether this is even possible. 所以我只是想知道这是否有可能。 if so some direction on how to get it done would be greatly appreciated . 如果是这样,将会非常感激如何完成它的方向。 thanks 谢谢
The new myJsonStore();
new myJsonStore();
only creates a new store. 仅创建一个新商店。 In order to reference the store elsewhere in your code ( same file or another file) you need to use a variable. 为了在代码的其他位置(同一文件或另一个文件)引用存储,您需要使用一个变量。 Create the store like this: 像这样创建商店:
var myStore = new myJsonStore();
And to bind it to the comobobox use the variable name myStore
with the store
property. 要将其绑定到comobobox,请使用带有store
属性的变量名称myStore
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.