如何从Extjs 5.0中的FormPanel获取所有项目?
Ext.ComponentQuery.query('#ownform')[0].query('.field').forEach(function(item){});
代码适用于文本框和组合框,但我的表单包含网格和按钮等。
答案 0 :(得分:0)
我的建议是,尝试首先获取基本表单myform.getForm(),然后使用getFields方法,如下例所示。
var form = this.up('form').getForm();
form.getFields().each(function(item){
item.setRawValue('test1');
});
答案 1 :(得分:0)
取决于您的意思"来自FormPanel的所有项目"这个问题有不同的答案。
如果你想要所有后代物品/组件:
Ext.ComponentQuery.query('#ownform component');
如果你想要所有直接儿童用品/组件:
Ext.ComponentQuery.query('#ownform > component');
有关建立组件查询选择器的更多信息,请参阅Ext JS 5.0 Ext.ComponentQuery doc。