How to get all items from the FormPanel in Extjs 5.0?
如何从Extjs 5.0中的FormPanel获取所有项目?
Ext.ComponentQuery.query('#ownform')[0].query('.field').forEach(function(item){});
The code is working for textbox and combobox but my form contains grids and buttons etc.
该代码适用于文本框和组合框,但我的表单包含网格和按钮等。
2 个解决方案
#1
0
My suggestion for you is , try to get the Basic Form first myform.getForm() and then use getFields method like example below .
我的建议是,尝试首先获取基本表单myform.getForm(),然后使用getFields方法,如下例所示。
var form = this.up('form').getForm();
form.getFields().each(function(item){
item.setRawValue('test1');
});
#2
0
Depending on what you mean by "all items from the FormPanel" there are different answers for this question.
根据“FormPanel中的所有项目”的含义,这个问题有不同的答案。
If you want all descendant items/Components:
如果你想要所有后代物品/组件:
Ext.ComponentQuery.query('#ownform component');
If you want all direct children items/Components:
如果你想要所有直接儿童用品/组件:
Ext.ComponentQuery.query('#ownform > component');
Please see the Ext JS 5.0 Ext.ComponentQuery doc for more information on buidling component query selectors.
有关buidling组件查询选择器的更多信息,请参阅Ext JS 5.0 Ext.ComponentQuery文档。
#1
0
My suggestion for you is , try to get the Basic Form first myform.getForm() and then use getFields method like example below .
我的建议是,尝试首先获取基本表单myform.getForm(),然后使用getFields方法,如下例所示。
var form = this.up('form').getForm();
form.getFields().each(function(item){
item.setRawValue('test1');
});
#2
0
Depending on what you mean by "all items from the FormPanel" there are different answers for this question.
根据“FormPanel中的所有项目”的含义,这个问题有不同的答案。
If you want all descendant items/Components:
如果你想要所有后代物品/组件:
Ext.ComponentQuery.query('#ownform component');
If you want all direct children items/Components:
如果你想要所有直接儿童用品/组件:
Ext.ComponentQuery.query('#ownform > component');
Please see the Ext JS 5.0 Ext.ComponentQuery doc for more information on buidling component query selectors.
有关buidling组件查询选择器的更多信息,请参阅Ext JS 5.0 Ext.ComponentQuery文档。