开发者

enabling/disabling checkbox according to some condition

I have a chechbox in a gridvi开发者_运维知识库ew. i need it disabled for some condition and enabled for other. Problem is how to fetch check box id out side the grid.

Please help ....


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:pw="http://intelligentpathways.com.au/Flex/v2">

    <mx:ArrayCollection id="ac">
        <mx:Object name="Alpha" enabled="{true}"/>
        <mx:Object name="Bravo" enabled="{true}"/>
        <mx:Object name="Charlie" enabled="{false}"/>
        <mx:Object name="Delta" enabled="{false}"/>
        <mx:Object name="Echo" enabled="{true}"/>
    </mx:ArrayCollection>

    <mx:Panel horizontalCenter="0" verticalCenter="0" title="Renderer Demo">
        <mx:DataGrid width="500" height="300" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Name" dataField="name"/>
                <mx:DataGridColumn headerText="Enabled?" dataField="enabled"/>
                <mx:DataGridColumn headerText="Checkbox">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:Box paddingLeft="3">
                                <mx:CheckBox label="Foxtrot" enabled="{data.enabled}"/>
                            </mx:Box>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>
    </mx:Panel>

</mx:Application>


By giving you're check box an ID you should be able to reference it no matter what container objects it's it.

<mx:CheckBox id=myCheckbox ... />

can then be referenced in any script in that file like this:

private function toggleCheckBoxEnabled():void{
    if(some condition){
      myCheckBox.enabled = true;
    }else{
      myCheckBox.enabled = false;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜