Using the Sencha Architect, I am facing the following problem in Sencha Touch 2: I can define models, read them from a JSONp proxy, no problem, but how can I define a model which itself contains an array of another model?
使用Sencha Architect,我在Sencha Touch 2中面临以下问题:我可以定义模型,从JSONp代理读取它们,没问题,但是如何定义一个本身包含另一个模型数组的模型?
The data is loaded fine, but the array of "sub"models is just a plain JS object, I cannot use any getters for instance. There is no link with the Ext Model definition...
数据加载正常,但“子”模型数组只是一个普通的JS对象,我不能使用任何getter。 Ext模型定义没有链接......
Thanks for the help
谢谢您的帮助
1 个解决方案
#1
1
First of all, make sure to define the relations between models using associations. Define getters and setters on the associations where needed. Then, load the data using a store which is referring to you top-level model. Call the getters of associated data on the store once loaded.
首先,确保使用关联定义模型之间的关系。在需要的地方定义关联的getter和setter。然后,使用引用您的*模型的商店加载数据。加载后调用商店中关联数据的getter。
#1
1
First of all, make sure to define the relations between models using associations. Define getters and setters on the associations where needed. Then, load the data using a store which is referring to you top-level model. Call the getters of associated data on the store once loaded.
首先,确保使用关联定义模型之间的关系。在需要的地方定义关联的getter和setter。然后,使用引用您的*模型的商店加载数据。加载后调用商店中关联数据的getter。