[英]IN CQ, how to set value of all the items in Panel to blank
In ExtJS panel
I need to set value of all items (eg textfield
, pathfield
) to blank. 在ExtJS
panel
我需要将所有项目(例如textfield
, pathfield
)的值设置为空白。 I don't want to set value of each individual item to blank but of whole panel in one go. 我不想一次性设置每个单独项目的值,而是整个面板的值。
I am able to get list of items 我能够得到物品清单
function getAllChildren (panel) {
/*Get children of passed panel or an empty array if it doesn't have thems.*/
var children = panel.items ? panel.items.items : [];
/*For each child get their children and concatenate to result.*/
CQ.Ext.each(children, function (child) {
children = children.concat(getAllChildren(child));
});
return children;
}
but how to set to blank for whole panel? 但是如何将整个面板设置为空白? Please suggest what need to be done in this case.
请提出在这种情况下需要做什么。
Actually, it's not possible to do it with one liner - all at the same time. 实际上,不可能同时使用一根衬垫。 What your method returns is purely an array of objects.
您的方法返回的纯粹是一个对象数组。 In fact if such syntax existed, it would iterate over all fields anyway.
实际上,如果存在这样的语法,则无论如何它将迭代所有字段。
Though clearing all fields, having the method you've proposed is very trivial to do. 尽管清除了所有字段,但采用您提出的方法却很简单。 Just iterate over them all and call
reset
method. 只需遍历它们并调用
reset
方法即可。 Mind some (especially custom) widgets might not handle it. 注意某些(特别是自定义)小部件可能无法处理。
var fields = getAllChildren(panel);
CQ.Ext.each(fields, function(field) {
if (child.reset) {
child.reset();
}
});
You've got similar loop in your getAllChildren
code - you might reset field at the same place. 在
getAllChildren
代码中有类似的循环-您可能会在同一位置重置字段。
The method is defined in Field
type which is usually a supertype of each dialog widget. 该方法在“
Field
类型”中定义,该类型通常是每个对话框小部件的超类型。 You can read more here . 您可以在这里阅读更多内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.