English 中文(简体)
部分等级——所有儿童部分
原标题:Extjs3 Component hierarchy - fetch all child components

我面临以下局势。

I have a formpanel, within this formpanel I have another tabpanel in which again form elements are placed that are part of the formpanel. Nothing spectacular. Basically a formpanel with some "subforms" each contained in a tab in a tabpanel.

现在,当用户在工具栏中点击一个纽子时,我添加了代码,使每个次形/表解体。 但是,为了证实残疾表上的所有表象,我还需要单独区分表层中的每一表层,以便在提交时能够验证。

That s when the trouble begins. Suppose in one of the tabs/subforms i have a fieldset with another nested fieldset. How can i fetch all xtype:field elements contained in the tab/subform?


因此,无论在组成部分等级的深度如何,基本上什么是一米的要求? 如果采用一种方法收集所有的儿童成分,那么就很容易将他们 lo为.,而残疾则真正从Ext.isXType(外地)返回,但是,如果提到含有成分的子伴侣,那么我就没有办法收集所有的子伴侣。

最佳回答

这样:

var componentsArray = container.findByType( component );

Or even this

var componentsArray = container.findBy(function(c) {return true});

(可能更快)

但应指出的是,这不会在<编码>tbar 、bbar <>/code>、buttons 特性Ext.Panel descendands内交还部件。

问题回答

<><>Edit>/strong> 参看Mchl的回答。 我对“Ext”文件中的错误感到误导。


页: 1

cascade( Function fn, [Object scope], [Array args] ) : Ext.Container

Cascades down the component/container heirarchy from this component (called first), calling the specified function with each component. The scope (this) of function call will be the scope provided or the current component. The arguments to the function will be the args provided or the current component. If the function returns false at any point, the cascade is stopped on that branch.

我在测试这一答案时使用了这一方法:

var children = [];
this.cascade(function(cmp) {
  if (cmp.isXType( field )) {
    children.push(cmp)
  }
});

<儿童代码>/编码>包含446个不同层次的实地情况。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.