hi Tracy, i tried doing as you said, i have my dataprovider (dataAr) which i
filter and then assign the result to another arraycollection (copydataAr) which
i then use as the dataprovider for my tilelist. this has not worked though.
maybe there is something am doing wrong. here is the code so far.
[Bindable]
private var dataAr:ArrayCollection = new ArrayCollection;
public function displayResult(event:ResultEvent):void{
dataAr = new ArrayCollection((event.result as
ArrayCollection).source);
}
[Bindable]
private var copydataAr:ArrayCollection = cloneCollection(dataAr);
private function filterGrid():void{
dataAr.filterFunction=myFilterFunction;
}
private function myFilterFunction(item:Object):Boolean{
return(item.city == selectedCity || selectedCity == "All") &&
(item.location == selectedLocation || selectedLocation == "All") &&
(item.bedrooms == selectedbdrm || selectedbdrm == "-- Choose One --")
&&
(item.bathrooms == selectedbathrm || selectedbathrm == "-- Choose One
--") &&
(item.category == category.selectedValue)&&
(!garageSelected || item.garages)&&
(!tileflrSelected || item.tile_floor)&&
(!hardwoodflrSelected || item.hardwood_floor)&&
(!laminateflrSelected || item.laminate_floor)&&
(!balconySelected || item.balcony)&&
(!yardSelected || item.backyard)&&
(!closetSelected || item.closets)&&
(!poolSelected || item.pool);
}
private function
cloneCollection(dataAr:ArrayCollection):ArrayCollection{
var copydataAr:ArrayCollection = new ArrayCollection();
copydataAr.source = copydataAr.source.concat(dataAr.source);
return copydataAr;
}
// Syncs destination collection2 to source collection1, removing or
adding items as necessary. Assumes the source collection is sorted
private function syncCollection(collection1:ArrayCollection,
collection2:ArrayCollection):void{
var idx:int = 0;
while (idx < collection1.length && idx < collection2.length)
if (collection2[idx] < collection1[idx])
collection2.removeItemAt(idx);
else{
if (collection2[idx] > collection1[idx])
collection2.addItemAt(collection1[idx],idx)
idx++;
}
while (idx < collection1.length)
collection2.addItemAt(collection1[idx],idx++);
while (idx < collection2.length)
collection2.removeItemAt(idx);
}
then on the individual components,
private function cityChangeHandler(event:Event):void{
if( city_cb.selectedItem != null )
selectedCity = city_cb.selectedLabel;
filterGrid();
dataAr.refresh();
syncCollection(dataAr,copydataAr);
currentState = '';
}
private function locationChangeHandler(event:Event):void{
if( lct_cb.selectedItem != null )
selectedLocation = lct_cb.selectedLabel;
filterGrid();
dataAr.refresh();
syncCollection(dataAr,copydataAr);
currentState = '';
} etc