Thank you for your help! Finaly, the
http://www.cflex.net/showFileDetails.cfm?ObjectID=415&Object=File&ChannelID=1
option.
The logic of this thing is to copy the collection in a array and push
the reset value in. If the collection change, we need to repopulate de
fake array.
//////////////MAIN ACTIONSCRIPT//////////////
[Bindable]
public var categoryFilter : Array = new
ArrayFilter(myModel.categoryData,"Show All");
private function checkIfShowAll(item:Object):Boolean{
return item.hasOwnProperty("resetFilter")&& item.resetFilter
}
private function initApp():void{
myCustomEntry.filterFunction = globalFilter
myCustomEntry.refresh()
}
private function globalFilter(o:Object):Boolean {
var show:Boolean=true
if(!checkIfShowAll(cboLayer.selectedItem) &&
cboLayer.selectedItem!=null && o.layer!=cboLayer.selectedItem ){
show = false
}
return show
}
...
//////////////MAIN MXML//////////////
<mx:ComboBox id="cboLayer" width="169" x="61" y="2"
change="myCustomEntry.refresh()"
dataProvider="{layerFilter}" labelField="name" />
...
/////////////ArrayFilter CLASS//////////////
dynamic public class ArrayFilter extends Array{
import mx.collections.ArrayCollection
import mx.events.CollectionEvent;
private var resetString:String;
private var sourceFilterCollection:ArrayCollection;
public function
ArrayFilter(sourceFilterCollection:ArrayCollection,resetString:String="All"):void{
super()
this.sourceFilterCollection=sourceFilterCollection;
this.sourceFilterCollection.addEventListener(CollectionEvent.COLLECTION_CHANGE,refreshMyArray)
this.resetString=resetString;
refreshMyArray(new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE))
}
public function refreshMyArray(event:CollectionEvent):void
{
//remove all and insert after (will be better to check
CollectionEvent...)
this.splice(0,this.length)
var n:int = sourceFilterCollection.source.length;
for (var i:int = 0; i < n; i++){
this.push(sourceFilterCollection.source[i]);
}
this.sort();
var o:Object = new Object();
o.resetFilter=true;
o.toString=function():String{
return resetString;
}
this.unshift(o);
}
}
--- In [email protected], "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
>
> Hi David,
>
> You could use the prompt property. But, that won't allow you to reset
> the filter. This might give you some ideas:
>
>
http://www.cflex.net/showFileDetails.cfm?ObjectID=415&Object=File&Channe\
> lID=1
>
<http://www.cflex.net/showFileDetails.cfm?ObjectID=415&Object=File&Chann\
> elID=1>
>
> -TH
> __________________________________
>
> Tim Hoff
> Cynergy Systems, Inc.
> http://www.cynergysystems.com
> Office <http://www.cynergysystems.comoffice/> : 866-CYNERGY
>
> --- In [email protected], "Doug Lowder" <douglowder@> wrote:
> >
> > ComboBox has a property named "prompt" that may do what you want.
> >
> > <mx:ComboBox dataProvider="{layerData}" y="10" x="106"
> > prompt="No selection"/>
> >
> >
> > --- In [email protected], "nxzone" nxzone@ wrote:
> > >
> > > Hi,
> > >
> > > For my first post, i have a hard question.
> > >
> > > *I have ComboxBox filled by a Bindable ArrayCollection.
> > > *This ComboxBox will act as a Filter.
> > > The problem is: how can a add a value "No selection" or "No filter"
> > > only to this ComboBox.
> > > *Important, i don't want add this in my model, only in the
> > > combobox...
> > >
> > >
> > >
> > > Short example
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > > layout="absolute">
> > > <mx:Script>
> > > <![CDATA[
> > > import mx.collections.ArrayCollection;
> > > [Bindable]
> > > public var layerData:ArrayCollection= new ArrayCollection
> > > (["Item a","Item c","Item d","Item e","Item f","Item g","Item h"])
> > >
> > > ]]>
> > > </mx:Script>
> > > <mx:Label text="Show only ->" x="10" y="12"/>
> > >
> > > <mx:ComboBox dataProvider="{layerData}" y="10" x="106"/>
> > > <mx:List dataProvider="{layerData}" x="10" y="38"
> > > width="243" height="168"></mx:List>
> > > </mx:Application>
> > >
> > >
> > > ***This will be use in a opensource Timeline project in Flex 2. If
> > > you are interessed to participate, email me to dblais@
> > > http://www.ideeclic.com/clients/133-cspi/v4/index.html
> > > Go to "Mes lignes du temps"->"Cr�er une ligne du temps"
> > >
> > > David Blais
> > > Thank you!
> > >
> >
>