You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2016/06/17 16:11:05 UTC
Flex - Disable an item with checkbox in List
I have a List with checkboxes. I wan to disable some items based on List's
data.
Here is my List:
<mx:List id="templateList" width="100%" alternatingItemColors="[#EEEEEE,
white]"
labelField="Name" selectedIndex="0">
<mx:itemRenderer>
<mx:Component>
<templateFilterCheckBox/>
</mx:Component>
</mx:itemRenderer>
</mx:List>
<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox selectedField="isSelected" change="onChange(event)"
enabled="{data.enabled}"
xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function onChange(event:Event):void
{
data.isSelected = !data.isSelected;
var _changeComplete:Event = new Event("filterChangeComplete", true);
dispatchEvent(_changeComplete);
}
]]>
</mx:Script>
</mx:CheckBox>
I have set data.enabled to false for all items just for testing. None of
checkboxes come out disabled. The data provider is an AraayCollection and
bindable.
Any idea what is missed?
Thanks
Re: Flex - Disable an item with checkbox in List
Posted by mark goldin <ma...@gmail.com>.
That should work. But I have done it differently.
Here is a custom List component:
<?xml version="1.0" encoding="utf-8"?>
<mx:List xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.listClasses.IListItemRenderer;
override protected function drawItem(item:IListItemRenderer,
selected:Boolean=false, highlighted:Boolean=false,
caret:Boolean=false, transition:Boolean=false):void
{
item.enabled = item.data.enabled;
super.drawItem(item, selected, highlighted && item.enabled, caret,
transition);
}
]]>
</mx:Script>
</mx:List>
Credit to an article on the Web.
On Fri, Jun 17, 2016 at 12:46 PM Alex Harui <ah...@adobe.com> wrote:
> Maybe this?
> http://blogs.adobe.com/aharui/2007/06/disabling_list_selection.html
>
> On 6/17/16, 9:11 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >I have a List with checkboxes. I wan to disable some items based on List's
> >data.
> >
> >Here is my List:
> >
> ><mx:List id="templateList" width="100%" alternatingItemColors="[#EEEEEE,
> >white]"
> >labelField="Name" selectedIndex="0">
> ><mx:itemRenderer>
> ><mx:Component>
> ><templateFilterCheckBox/>
> ></mx:Component>
> ></mx:itemRenderer>
> ></mx:List>
> >
> ><?xml version="1.0" encoding="utf-8"?>
> ><mx:CheckBox selectedField="isSelected" change="onChange(event)"
> >enabled="{data.enabled}"
> >xmlns:mx="http://www.adobe.com/2006/mxml">
> ><mx:Script>
> ><![CDATA[
> >private function onChange(event:Event):void
> >{
> >data.isSelected = !data.isSelected;
> >var _changeComplete:Event = new Event("filterChangeComplete", true);
> >dispatchEvent(_changeComplete);
> >}
> >]]>
> ></mx:Script>
> ></mx:CheckBox>
> >
> >I have set data.enabled to false for all items just for testing. None of
> >checkboxes come out disabled. The data provider is an AraayCollection and
> >bindable.
> >Any idea what is missed?
> >
> >Thanks
>
>
Re: Flex - Disable an item with checkbox in List
Posted by Alex Harui <ah...@adobe.com>.
Maybe this?
http://blogs.adobe.com/aharui/2007/06/disabling_list_selection.html
On 6/17/16, 9:11 AM, "mark goldin" <ma...@gmail.com> wrote:
>I have a List with checkboxes. I wan to disable some items based on List's
>data.
>
>Here is my List:
>
><mx:List id="templateList" width="100%" alternatingItemColors="[#EEEEEE,
>white]"
>labelField="Name" selectedIndex="0">
><mx:itemRenderer>
><mx:Component>
><templateFilterCheckBox/>
></mx:Component>
></mx:itemRenderer>
></mx:List>
>
><?xml version="1.0" encoding="utf-8"?>
><mx:CheckBox selectedField="isSelected" change="onChange(event)"
>enabled="{data.enabled}"
>xmlns:mx="http://www.adobe.com/2006/mxml">
><mx:Script>
><![CDATA[
>private function onChange(event:Event):void
>{
>data.isSelected = !data.isSelected;
>var _changeComplete:Event = new Event("filterChangeComplete", true);
>dispatchEvent(_changeComplete);
>}
>]]>
></mx:Script>
></mx:CheckBox>
>
>I have set data.enabled to false for all items just for testing. None of
>checkboxes come out disabled. The data provider is an AraayCollection and
>bindable.
>Any idea what is missed?
>
>Thanks