|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
multiple filter function of combobox and two checkboxeshi guys, this is the biggest obstacle i have face ever since i started coding in flex. i kindly ask for an example of filtering an array collection using two checkboxes and a combobox. thanks
|
|
|
Re: multiple filter function of combobox and two checkboxesWhile I don't have an example handy I can hopefully put you on the path.
First thing, it doesn't matter what controls you are using to set the filter: the filter will function in the exact same way. For CheckBox and ComboBox you pretty much just listen for the "change" event and filter when the event fires. Another thing to note is that ArrayCollection is basically just a wrapper for Array. So you can easily convert your ArrayCollection to an Array by calling the toArray method and then take advantage of Array's filter method (http://livedocs.adobe.com/flex/3/langref/Array.html#filter%28%29). When you're done just convert your Array back to an ArrayCollection with a statement like "new ArrayCollection(myFilteredArray)". --- In flexcoders@..., "stinasius" <stinasius@...> wrote: > > hi guys, this is the biggest obstacle i have face ever since i started coding in flex. i kindly ask for an example of filtering an array collection using two checkboxes and a combobox. thanks > |
|
|
Re: multiple filter function of combobox and two checkboxesi know that the filter function will work the same way. but i have a problem with integrating a checkbox filter into a large multi filter function. let me explain... i have a number of controls that am currently using to filter data from a database. so i developed a multi filter function to handle the filtering depending on what control is picked by the user. it works well but one problem i have is that i have failed to find a way to include a checkbox control into the multi filter function. below is the multi filter function am using and would like to include a checkbox filter to it.
private var sliderFromValue : Number = 0; private var sliderToValue : Number = 3000000; private var selectedCity : String = "All"; private var selectedLocation : String = "All"; private var selectedValue: Boolean; private var poolSelected: Boolean = false; private function onSliderChange(event:SliderEvent):void { var slider:Slider = Slider(event.currentTarget) ; sliderFromValue = priceSlider.values[0]; sliderToValue = priceSlider.values[1]; filterGrid() ; currentState = ''; } private function cityChangeHandler(event:Event):void { if( city_cb.selectedItem != null ) selectedCity = city_cb.selectedLabel; filterGrid(); currentState = ''; } private function locationChangeHandler(event:Event):void { if( lct_cb.selectedItem != null ) selectedLocation = lct_cb.selectedLabel; filterGrid(); currentState = ''; } private function categoryChangeHandler(event:Event):void { if(category.selectedValue != null) selectedValue = category.selectedValue; filterGrid(); currentState = ''; } private function poolFilter():void { poolSelected = pool_ckb.selected; filterGrid(); currentState = ''; } private function filterGrid() :void { dataAr.filterFunction=myFilterFunction; dataAr.refresh(); } private function myFilterFunction(item:Object): Boolean { return(item.price >= sliderFromValue && item.price <= sliderToValue)&& (item.city == selectedCity || selectedCity == "All") && (item.location == selectedLocation || selectedLocation == "All") && (item.category == category.selectedValue)&& (item.pool == poolSelected); } the individual filter functions are attached to individual controls but the poolfilter is the one that is troubling me. |
|
|
Re: multiple filter function of combobox and two checkboxesok... i have officially failed to get this working so here is my proposal, i will pay to get this done for me. anyone out there willing to write the whole multifilter function from the ground up please let me know so we can negotiate the price. you can get to me on my email address "stinasius@..."
|
|
|
RE: Re: multiple filter function of combobox and two checkboxesJumping into this thread late, what didn't work with the code you posted
on Tuesday? Gk. Gregor Kiddie Senior Developer INPS Tel: 01382 564343 Registered address: The Bread Factory, 1a Broughton Street, London SW8 3QJ Registered Number: 1788577 Registered in the UK Visit our Internet Web site at www.inps.co.uk <blocked::http://www.inps.co.uk/> The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of INPS or any of its affiliates. If you are not the intended recipient please contact is.helpdesk@... |
|
|
Re: multiple filter function of combobox and two checkboxeswell, am trying to integrate some checkbox filter into a multiple filter function and its giving me hell. basically am trying to filter an arraycollection based on multiple criteria using different components like slider, combo box, radio buttons and check boxes. while i have the rest of the component filters working, i cant figure out a way to include the checkbox filter into the filter function. here is my code so far.
////////////////////////filters////////////////////////////////////////////////////////////////////////// private var sliderFromValue : Number = 0; private var sliderToValue : Number = 3000000; private var selectedCity : String = "All"; private var selectedLocation : String = "All"; private var selectedValue: Boolean; private var poolSelected: Boolean = false; private function onSliderChange(event:SliderEvent):void { var slider:Slider = Slider(event.currentTarget) ; sliderFromValue = priceSlider.values[0]; sliderToValue = priceSlider.values[1]; filterGrid() ; currentState = ''; } private function cityChangeHandler(event:Event):void { if( city_cb.selectedItem != null ) selectedCity = city_cb.selectedLabel; filterGrid(); currentState = ''; } private function locationChangeHandler(event:Event):void { if( lct_cb.selectedItem != null ) selectedLocation = lct_cb.selectedLabel; filterGrid(); currentState = ''; } private function categoryChangeHandler(event:Event):void { if(category.selectedValue != null) selectedValue = category.selectedValue; filterGrid(); currentState = ''; } private function poolFilter():void { poolSelected = pool_ckb.selected; filterGrid(); currentState = ''; } private function filterGrid() :void { dataAr.filterFunction=myFilterFunction; dataAr.refresh(); } private function myFilterFunction(item:Object): Boolean { return(item.price >= sliderFromValue && item.price <= sliderToValue)&& (item.city == selectedCity || selectedCity == "All") && (item.location == selectedLocation || selectedLocation == "All") && (item.category == category.selectedValue)&& (item.pool == poolSelected); } there is something wrong with the poolfilter function which affects the general filter function. i would like that if someone clicked the pool checkbox, only property with pools show and if they uncheck it, then all property shows up. |
|
|
RE: Re: multiple filter function of combobox and two checkboxesAh ok... I've got you. How about trying this for the filter function?
private function myFilterFunction(item:Object): Boolean { return(item.price >= sliderFromValue && item.price <= sliderToValue)&& (item.city == selectedCity || selectedCity == "All") && (item.location == selectedLocation || selectedLocation == "All") && (item.category == category.selectedValue)&& (!poolSelected || item.pool); } The (!poolSelected || item.pool) will equate to true when the checkbox isn't selected (!poolSelected ) or when the item has a pool when the checkbox is selected (item.pool). Gk. Gregor Kiddie Senior Developer INPS Tel: 01382 564343 Registered address: The Bread Factory, 1a Broughton Street, London SW8 3QJ Registered Number: 1788577 Registered in the UK Visit our Internet Web site at www.inps.co.uk <blocked::http://www.inps.co.uk/> The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of INPS or any of its affiliates. If you are not the intended recipient please contact is.helpdesk@... ________________________________ From: flexcoders@... [mailto:flexcoders@...] On Behalf Of stinasius Sent: 04 November 2009 13:31 To: flexcoders@... Subject: [flexcoders] Re: multiple filter function of combobox and two checkboxes well, am trying to integrate some checkbox filter into a multiple filter function and its giving me hell. basically am trying to filter an arraycollection based on multiple criteria using different components like slider, combo box, radio buttons and check boxes. while i have the rest of the component filters working, i cant figure out a way to include the checkbox filter into the filter function. here is my code so far. ////////////////////////filters///////////////////////////////////////// ///////////////////////////////// private var sliderFromValue : Number = 0; private var sliderToValue : Number = 3000000; private var selectedCity : String = "All"; private var selectedLocation : String = "All"; private var selectedValue: Boolean; private var poolSelected: Boolean = false; private function onSliderChange(event:SliderEvent):void { var slider:Slider = Slider(event.currentTarget) ; sliderFromValue = priceSlider.values[0]; sliderToValue = priceSlider.values[1]; filterGrid() ; currentState = ''; } private function cityChangeHandler(event:Event):void { if( city_cb.selectedItem != null ) selectedCity = city_cb.selectedLabel; filterGrid(); currentState = ''; } private function locationChangeHandler(event:Event):void { if( lct_cb.selectedItem != null ) selectedLocation = lct_cb.selectedLabel; filterGrid(); currentState = ''; } private function categoryChangeHandler(event:Event):void { if(category.selectedValue != null) selectedValue = category.selectedValue; filterGrid(); currentState = ''; } private function poolFilter():void { poolSelected = pool_ckb.selected; filterGrid(); currentState = ''; } private function filterGrid() :void { dataAr.filterFunction=myFilterFunction; dataAr.refresh(); } private function myFilterFunction(item:Object): Boolean { return(item.price >= sliderFromValue && item.price <= sliderToValue)&& (item.city == selectedCity || selectedCity == "All") && (item.location == selectedLocation || selectedLocation == "All") && (item.category == category.selectedValue)&& (item.pool == poolSelected); } there is something wrong with the poolfilter function which affects the general filter function. i would like that if someone clicked the pool checkbox, only property with pools show and if they uncheck it, then all property shows up. |
|
|
Re: multiple filter function of combobox and two checkboxeswow Gregor you are a genius. your solution has finally worked for me after such a long time with this problem.. thanks alot and thanks to all the guys contributing on this forum.
|
| Free embeddable forum powered by Nabble | Forum Help |