Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 改变;已启用";flex中运行时按钮的值_Apache Flex_Actionscript 3_Actionscript_Button_Mxml - Fatal编程技术网

Apache flex 改变;已启用";flex中运行时按钮的值

Apache flex 改变;已启用";flex中运行时按钮的值,apache-flex,actionscript-3,actionscript,button,mxml,Apache Flex,Actionscript 3,Actionscript,Button,Mxml,如果datagrid为空,我想禁用一个按钮,当至少有1个条目时,应该启用该按钮。网格中的条目是在运行时生成的。我尝试了此操作 这是按钮: <mx:Button id="update" label="Update Contact" enabled="{isButtonEnabled()}"/> 我哪里出错了?您的代码不工作,因为isButtonEnabled()在选择的索引发生更改时不会被调用。您可以使用BindingUtils来执行此操作,但这可以在没有BindingUtils D

如果datagrid为空,我想禁用一个按钮,当至少有1个条目时,应该启用该按钮。网格中的条目是在运行时生成的。我尝试了此操作 这是按钮:

<mx:Button id="update" label="Update Contact" enabled="{isButtonEnabled()}"/>

我哪里出错了?

您的代码不工作,因为
isButtonEnabled()
选择的索引发生更改时不会被调用。您可以使用
BindingUtils
来执行此操作,但这可以在没有
BindingUtils

DataGrid
可以包含项目,但其
selectedIndex
可以等于-1。如果您不担心某个项目是否被选中,请将其绑定到
DataGrid
dataProvider

<mx:Button id="update" label="Update Contact" 
               enabled="{dg_contact.dataProvider.length != 0}"/>
<mx:Button id="update" label="Update Contact" 
               enabled="{dg_contact.dataProvider.length != 0}"/>
<mx:Button id="update" label="Update Contact" 
               enabled="{dg_contact.selectedIndex != -1}"/>