为什么不是我的ExtJS的商店会工作 [英] Why isn't my ExtJS Store Association Working

查看:155
本文介绍了为什么不是我的ExtJS的商店会工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题。我想用漂亮的ExtJS的协会,但他们无法正常工作。

I'm having issues. I want to use the nice ExtJS associations, but they're not working properly.

问题:


  • 没有关联的模型显示了

  • 无数据显示负载经过长达

有什么需要注意的怪癖?

What are the quirks to watch out for?

推荐答案

我最近通过与联想的ExtJS一个非常痛苦的学习曲线去了,发现一些有用的文章来了,还有我自己的陷阱。这里是为那些谁遇到同样的痛苦摘要。

I recently went through a very painful learning curve with the ExtJS associations, and came across some useful articles, as well as my own gotchas. Here is the summary for those who run into the same pains.

规则中的ExtJS的hasMany关联


  • 总是把你的代理服务器在你的模型,不是你的店铺,除非你
    有一个很好的理由不[1]

  • 总是要求你的孩子如果模型
    用他们的hasMany关系。 [2]

  • 如果你想你可以随意加载孩子始终使用FOREIGNKEY

  • 始终使用associationKey如果你作为父母相同的响应返回儿童

  • 您可以同时使用FOREIGNKEY和associationKey如果你喜欢

  • 总是命名您的hasMany关系

  • 在您的hasMany关系始终使用完全合格的型号名称

  • 考虑给读者根一个有意义的名字(不是数据等)

  • 子模型不需要关系的belongsTo为的hasMany工作

[1]这家商店将继承其模型的代理,你可以随时覆盖它

[2]为了方便,并避免潜在的循环引用,你可以要求他们在app.js

[1] The store will inherit its model's proxy, and you can always override it
[2] To make it easy, and avoid potential circular references, you can require them in app.js

<一个href=\"http://extjs-tutorials.blogspot.com/2012/05/extjs-hasmany-relationships-rules.html\">http://extjs-tutorials.blogspot.com/2012/05/extjs-hasmany-relationships-rules.html

规则在ExtJS的HasOne和协会的belongsTo


  • 放入模型中的代理,除非你有一个很好的理由不要

  • 始终使用完全合格的型号名称

  • 务必将getterName

  • 务必将setterName

  • 始终将associationKey,如果异物是与此对象相同的响应返回

  • 始终设置ForeignKey的,如果你想你可以随意加载异物

  • 考虑更改实例名的东西短

  • getter方法​​表现的不同取决于异物是否加载
    或不。如果它的加载,则返回异物。除此以外,
    你需要一个回调来传递得到它。

  • 如果您打算重写这个协会应该设置name属性。

  • 您不需要关系的belongsTo为的hasMany工作

  • 将PrimaryKey属性如果父模型的id字段是不是ID

  • 有时你需要使用用途或要求对协会的belongsTo。看
    出循环引用,但。

  • 调用setter方法​​()函数
    似乎没有设置实例。设置object.belongsToInstance =如果OBJ
    调用setter方法​​()。

<一个href=\"http://extjs-tutorials.blogspot.com/2012/05/extjs-belongsto-association-rules.html\">http://extjs-tutorials.blogspot.com/2012/05/extjs-belongsto-association-rules.html

其它


  • 如果你申请你的数据网格,确保你调用使用新的存储网格上的重新配置()

  • 您FOREIGNKEY属性的将会的应用作为本地过滤器ExtJS的商店;如果你看到在网络上的数据加载,但
    网格中没有显示,请确保您的模型具有FOREIGNKEY
    值定义为字段,或本地过滤器将排除的数据
    quiety。为了测试,如果是这样的话,勾进店的负荷
    事件和呼叫store.clearFilters(),看看你的数据显示,高达

  • If you're applying your data to a grid, make sure you call reconfigure() on the grid using the new store
  • Your "foreignKey" property will be applied as a local filter to the ExtJS store; if you see the data loading over the network, but not showing in your grid, make sure your model has the foreignKey value defined as a field, or the local filter will exclude the data quiety. To test if this is the case, hook into the store's "load" event and call store.clearFilters(), and see if your data shows up

这篇关于为什么不是我的ExtJS的商店会工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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