使用itemId来获取组件Extjs [英] Using itemId to fetch component Extjs

查看:481
本文介绍了使用itemId来获取组件Extjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在选项卡渲染中有问题。当我在所有选项卡上使用相同的组件时,该组件的内容被混合,组件具有id的子组件。由于所有面板上的id都会相同,所以组件用于混合。我现在使用itemId而不是id,并且标签正在正确地呈现。
现在我面临另一个问题。最初我使用Ext.getCmp(id)来获取控制器中的组件。现在ids被itemId替换,我使用以下命令:
Ext.getCmp(íd).getComponent(itemId);



有一个深嵌套的视图中的组件以及所有中间组件都有itemId。使用上述语句,当我继续获取更深入的组件时,语句继续扩展:



Ext.getCmp(íd).getComponent(itemId1).getComponent(itemId2 ).getComponent(....;



我正在使用该语句?有没有更好的速记方法来达到目的?



请咨询。

解决方案

您可以使用Ext.ComponentQuery.query(..)或down ()或up()来获取所指向的组件。



如果要在某个组件内部获取组件(比如按钮)容器),您可以使用

  var button = Ext.ComponentQuery.query('button [type = messageButton]',this) ; 

在上述this是指容器范围。



或者您可以使用

  var button = this.query('button [type = messageButton]' ); 

在上面的这是指货柜范围。



希望这可以帮助你..


I had a problem with tab rendering. The contents of the tabs used to get mixed up as i used the same component on all the tabs and the component had sub-components with id. As the id would appear same on all panels, the components used to get mixed up. I am now using itemId instead of id and the tabs are getting rendered properly. Now I am facing another problem. Initially I used Ext.getCmp(id) to fetch components in the controller. Now that ids are replaced by itemId, I am using the following: Ext.getCmp(íd).getComponent(itemId);

There is a deep nesting of components in the view and all the intermediate components have itemId. With the above statement, as I go on to fetch deeper components, the statements keeps extending like:

Ext.getCmp(íd).getComponent(itemId1).getComponent(itemId2).getComponent(....;

Am I using the statement correctly? Is there a better shorthand method to achieve the purpose?

Please advice.

解决方案

You can use the Ext.ComponentQuery.query(..) or down() or up() to get the component you are referring to.

If you want to get a component(say a button) within a certain component(say within a container) ,you can use

 var button = Ext.ComponentQuery.query('button[type=messageButton]', this);

In the above 'this' refers to the container scope.

Or you can use

var button = this.query('button[type=messageButton]');

In the above also 'this' refers to the container scope.

Hope this helps you ..

这篇关于使用itemId来获取组件Extjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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