Extjs 4 动态添加多个面板到表单
我有 3 个面板,每个面板有 7 - 10 个字段。
主表单面板包含一个组合字段和 3 个面板。
根据组合选择的值,我隐藏剩余的 2 个面板并显示 1 个面板。
所有这三个面板都有 allowBlank: false
字段验证。
提交表单时,隐藏的字段也会被验证并阻止表单提交。所以我想禁用隐藏的字段。我正在使用这个代码。
question_multiple_option.query('.component').forEach(function(c){c.setDisabled(true);});
但在 EXT 4.X 中,提交表单时也会验证禁用的字段。
在 Ext 2.X 和 3.X 中,禁用字段不会被验证,也不会被提交。
以前我在 ext 2.X 中使用过这段代码,
Ext.getCmp('option').cascade(function(comp){
if (comp.isFormField) {
//comp.enable();
comp.disable();
}
});
这是通过隐藏和显示面板来实现具有多个面板的表单的正确方法吗?或者我如何动态添加/删除面板到表单?
有没有更好的方法来实现这种形式。
谢谢。
I have 3 panels and each panel will have 7 - 10 fields.
The main form panel contains a combo field and the 3 panels.
Based on the combo selected value i'm hiding the remaining 2 panels and showing one panel.
All these three panels have allowBlank: false
validations for the fields.
While submitting the form, the fields which are hidden are also validated and prevents the form from submitting. So i want to disable the fields which are hidden. i'm using this code.
question_multiple_option.query('.component').forEach(function(c){c.setDisabled(true);});
But in EXT 4.X disabled fields are also validated while submitting a form.
In Ext 2.X and 3.X disabled fields are not validated and not submitted.
previously i used this code in ext 2.X
Ext.getCmp('option').cascade(function(comp){
if (comp.isFormField) {
//comp.enable();
comp.disable();
}
});
Is it the right way to implement a form with multiple panels by hide and showing the panels. Or how can i add / remove a panel to a form dynamically ?.
Is there any better way to implement this kind of form.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
q 措辞很好。
它不应该验证禁用的字段。
有一个错误 关于这个问题已在 4.1 中修复。我不确定它在您使用的任何 4.x 版本中的外观如何,但您可以在代码中将覆盖添加到 Ext.form.field.Base 的
isValid
方法以匹配 4.1 代码如果你不能迁移。像这样的事情:Nicely phrased q.
It is not supposed to be validating disabled fields.
There was a bug about this that was fixed in 4.1. I'm not sure how it looks in whatever 4.x version you are using but you could add an override in your code to the
isValid
method of Ext.form.field.Base to match the 4.1 code if you can't migrate. Something like this: