Sencha Touch/ExtJS:如何动态定义模型?
我想动态定义模型来处理数据存储中的数据。 我有一个返回不同 JSON 结构的 Web 服务(例如 field_1:"val1"
或 field_1:"val1 field_2:"val2"
或 field_1:"val1 "...field_n:"valn"
)。我发现使用时
Ext.regStore("UserStuffStore",{
model: "myModel",
proxy: {
type: 'ajax',
url: rl,
headers: {
'Accept' : 'application/json'
},
reader: {
type: 'json'
}
},
autoLoad: true
});
需要指定一个模型。在这种情况下,我需要在定义模型之前查看数据结构。我该如何解决这个问题?
我当然可以做两个不同的调用Web服务(第一个获取数据结构,另一个获取数据),还有其他方法吗?
I would like to dynamically define models to handle data from a data store.
I have a web service that returns different JSON structures (eg. field_1:"val1"
or field_1:"val1 field_2:"val2"
or field_1:"val1"...field_n:"valn"
). I've seen that for using
Ext.regStore("UserStuffStore",{
model: "myModel",
proxy: {
type: 'ajax',
url: rl,
headers: {
'Accept' : 'application/json'
},
reader: {
type: 'json'
}
},
autoLoad: true
});
I need to specify a model. In this case, I need to see data structures before defining the model. How can I solve it?
Surely I can make two different calls to the web service (the first to get the data structures, the other to get data), is there another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未测试。我希望它有帮助:
另请参阅:Sencha 论坛
Not tested. I hope it helps:
Also see: Sencha forum