您的位置:首页 > 移动开发

Extjs4--- app(controller和application)相关问题

2012-04-17 20:26 309 查看
Controller中refs中的解释:

In the
refs
configuration,
you can set up references to view instances. This allows you to retrieve and manipulate components on the page inside of your controller’s actions. To describe the component that you want to reference, you can use a ComponentQuery inside the selector property.
The other required information inside of this object is the
ref
property.
This will be used as part of the name of the getter that will be generated automatically for each item inside the refs array. For example, by defining
ref:
'stationsList'
(note the capital L), a getter will be generated on the controller called
getStationsList
.
Alternatively, if you did not set up a reference inside your controller, you could continue to use
Ext.getCmp
inside
of the controller actions. However, we discourage you from doing this because it forces you to manage unique component ID's in your project, often leading to problems as your project grows.

It’s important to remember that these getters will be created independent of whether the view actually exists on the page. When you call the getter and the selector successfully matches a component on the page, it caches the result so that subsequent calls
to the getter will be fast. However, when the selector doesn’t match any views on the page, the getter will return null. This means that if you have logic that depends on a view and there is a possibility that the view does not exist on the page yet, you need
to add a check around your logic to ensure it only executes if the getter returned a result. In addition, if multiple components match the selector, only the first one will be returned. Thus, it’s good practice to make your selectors specific to the single
view you wish to get. Lastly, when you destroy a component you are referencing, calls to the getter will start returning null again until there is another component matching the selector on the page.

app.application和app.controller中getter自动方法的需要注意的问题:

It’s important to note that the getters for both views and models return a reference to the class (requiring you to instantiate
your own instances), while the getters for stores and controllers return actual instances.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐