如何在不为每个元素编写代码的情况下禁用 appmaker 中表单的所有元素?
How to disable all elements of a form in appmaker without writing code for each element?
我在 appmaker 中有一个表单,其中包含许多(至少 20-25 个)输入元素。
我想通过代码禁用所有这些元素,而无需为每个元素编写单独的禁用行代码。
我尝试使用 for 循环来执行类似下面的操作,但没有成功,因为它不对。
for(var i=0; i< app.currentPage.descendants.Form1.children.length; i++)
{
app.currentPage.descendants.Form1.children[0].enabled=false;
}
有没有办法一次性全部禁用它们?
这是未经测试的,但请尝试以下操作:
var children = app.currentPage.descendants.Form1Body.children._values;
for (var i in children) {
children[i].enabled = false;
}
请注意,我使用的是 Form1Body 而不是 Form1,因为顶部的 Form 元素由页眉、正文和页脚组成,因此当遍历 Form1 的子元素时,您实际上是在引用 3 个单独的面板而不是输入元素.
我在 appmaker 中有一个表单,其中包含许多(至少 20-25 个)输入元素。 我想通过代码禁用所有这些元素,而无需为每个元素编写单独的禁用行代码。
我尝试使用 for 循环来执行类似下面的操作,但没有成功,因为它不对。
for(var i=0; i< app.currentPage.descendants.Form1.children.length; i++)
{
app.currentPage.descendants.Form1.children[0].enabled=false;
}
有没有办法一次性全部禁用它们?
这是未经测试的,但请尝试以下操作:
var children = app.currentPage.descendants.Form1Body.children._values;
for (var i in children) {
children[i].enabled = false;
}
请注意,我使用的是 Form1Body 而不是 Form1,因为顶部的 Form 元素由页眉、正文和页脚组成,因此当遍历 Form1 的子元素时,您实际上是在引用 3 个单独的面板而不是输入元素.