Re: [flexcoders] Re: filter arraycollection with checkbox acting wired
Can you click on the checkbox more than once (let's say 5 times) and resend the output? Haykel Ben Jemia Allmas Web RIA Development http://www.allmas-tn.com On Tue, Feb 17, 2009 at 8:57 AM, johndoematrix johndoemat...@yahoo.comwrote: when i replace the code and run the app, i get the following output when i click the pizza_ckb checkbox and all the info disappears [SWF] /IE_V1/bin/portal_V1-debug.swf - 2,109,478 bytes after decompression true
Re: [flexcoders] Re: filter arraycollection with checkbox acting wired
It seems like your data is OK. So I did a test application and I figured out that the filter function is wrong. It should only do the test if the checkbox is selected, otherwise it should always return true because in this case you want display all items. So here is my working test app, I hope you can use it to make your code work: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=vertical mx:Script ![CDATA[ private var pizzaSelected:Boolean = false; private function pizzaFilter():void { pizzaSelected = pizza_ckb.selected; pizzaAr.refresh(); } private function myFilterFunction(item:Object):Boolean { if (pizzaSelected) return (item.pizza == pizzaSelected); else return true; } ]] /mx:Script mx:ArrayCollection id=pizzaAr filterFunction=myFilterFunction mx:Object label='Pizza 1' pizza='true' / mx:Object label='Not a pizza 1' pizza='false' / mx:Object label='Pizza 2' pizza='true' / mx:Object label='Pizza 3' pizza='true' / mx:Object label='Not a pizza 2' pizza='false' / /mx:ArrayCollection mx:CheckBox id=pizza_ckb change=pizzaFilter() / mx:List dataProvider={pizzaAr} labelField=label / /mx:Application Haykel Ben Jemia Allmas Web RIA Development http://www.allmas-tn.com On Tue, Feb 17, 2009 at 9:09 AM, johndoematrix johndoemat...@yahoo.comwrote: sorry i had forgotten to trace the item.pool. anyhow when i do that and i click the check box once i get true false true false true true when i click five times i get true false true false true true false false true false true true true false true false true true false false true false true true true false true false true true
RE: [flexcoders] Re: filter arraycollection with checkbox acting wired
I've quit this one. The original poster needs to develop his debugging techniques before going any further. Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Tim Hoff Sent: Tuesday, February 17, 2009 12:57 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: filter arraycollection with checkbox acting wired This is asolutely comical. -TH --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , johndoematrix johndoemat...@... wrote: hi Ben when i tried the solution you gave, it worked very very well. but this is when am using a single criteria. when i try to add it to a filter function that filter's based on more than one criteria that's when there come's a problem.
Re: [flexcoders] Re: filter arraycollection with checkbox acting wired
You have to review the logic of your filter function. As Tracy said, you should try to debug, this will save you a lot of time. Put a break point in the filter function and test your conditions. Haykel Ben Jemia Allmas Web RIA Development http://www.allmas-tn.com On Tue, Feb 17, 2009 at 1:23 PM, johndoematrix johndoemat...@yahoo.comwrote: hi Ben when i tried the solution you gave, it worked very very well. but this is when am using a single criteria. when i try to add it to a filter function that filter's based on more than one criteria that's when there come's a problem.
Re: [flexcoders] Re: filter arraycollection with checkbox acting wired
Replace the following functions, run the app in debug mode and post the output: private function pizzaFilter():void { trace(pizza_ckb.selected); if ( == true) pizzaSelected = pizza_ckb.data; filterGrid(); pizzaAr.refresh(); } private function myFilterFunction(item:Object): Boolean { trace(item.pizza); return (item.pizza == pizzaSelected) ; } Haykel Ben Jemia Allmas Web RIA Development http://www.allmas-tn.com On Tue, Feb 17, 2009 at 7:44 AM, johndoematrix johndoemat...@yahoo.comwrote: Hi, Tim i tried your code, but the result is not good too. when then check box is checked, all the data in the array collection disappears and when its unchecked all data shows up again. what i want to achieve is when the pizza_ckb is checked only the entries in the data base that have pizza show up and when i uncheck it all entries with or without pizza show up. thanks
RE: [flexcoders] Re: filter arraycollection with checkbox acting wired
I think I suggested already that you just need to debug this. Find an item that does not filter as you expect, step through the code til you hit that item, then step through the code to see why the filter function is not returning the expected value. It will almost certainly be obvious. For us to help, we need to do that process a a thought experiment. It will be much easier for you do do it in the debugger. Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of johndoematrix Sent: Friday, February 13, 2009 10:54 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: filter arraycollection with checkbox acting wired can someone please help me out here..thanks