I think if you use xmllist for dataprovider for your comboboxes then you can easily have chain effect as you said.
Hope this code snippet may help you. (replace the values according your requirements) var dp1:xmllist = new xmllist(dp0.data.(@field == val)); dp1.refresh(); Varun Bajaj On Fri, Jan 22, 2010 at 3:08 PM, Jitendra Jain < [email protected]> wrote: > Read about filter function it will be quite helpful. > > > On Fri, Jan 22, 2010 at 4:39 AM, Aviral Sharma <[email protected]>wrote: > >> Now, you can provide a dataprovider for combobox (using an >> arraycollection is better than hardcoding the data). >> Use filter function to remove duplicates as described in the link: >> >> http://blog.flexexamples.com/2007/08/05/removing-duplicate-items-from-an-array-using-the-arrayfilter-method/ >> >> Here is the code (visit the website link above to see a working >> example) >> >> <!-- Start Code --> >> >> <?xml version="1.0" encoding="utf-8"?> >> <!-- >> http://blog.flexexamples.com/2007/08/05/removing-duplicate-items-from-an-array-using-the-arrayfilter-method/ >> --> >> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >> layout="vertical" >> verticalAlign="middle" >> backgroundColor="white" >> creationComplete="init()"> >> >> <mx:Script> >> <![CDATA[ >> private var keys:Object = {}; >> >> /** >> * Called by the Application container's creationComplete >> * event handler. This method creates a new Array object >> * which will be used as a data provider as well as a >> * filtered view of that array which does not contain >> * duplicated items. >> */ >> private function init():void { >> /* Create a dummy data source with some semi-random >> data. */ >> var arr:Array = []; >> arr.push({data:1, label:"one"}); >> arr.push({data:1, label:"one"}); >> arr.push({data:1, label:"one"}); >> arr.push({data:1, label:"one"}); >> arr.push({data:2, label:"two"}); >> arr.push({data:2, label:"two"}); >> arr.push({data:2, label:"two"}); >> arr.push({data:1, label:"one"}); >> arr.push({data:3, label:"three"}); >> arr.push({data:3, label:"three"}); >> >> /* Filter the original array and call the >> removeDuplicates() function on each item >> in the array. */ >> var filteredArr:Array = arr.filter(removedDuplicates); >> >> arrColl.source = arr; >> dedupedArrColl.source = filteredArr; >> } >> >> /** >> * This method is used to filter an array so that no >> * duplicate items are created. It works by first >> * checking to see if a keys object already contains >> * a key equal to the current value of the item.data >> * value. If the key already exists, the current item >> * will not be readded to the data provider. If the key >> * does not already exist, add the key to the keys >> * object and add this item to the data provider. >> */ >> private function removedDuplicates(item:Object, idx:uint, >> arr:Array):Boolean { >> if (keys.hasOwnProperty(item.data)) { >> /* If the keys Object already has this property, >> return false and discard this item. */ >> return false; >> } else { >> /* Else the keys Object does *NOT* already have >> this key, so add this item to the new data >> provider. */ >> keys[item.data] = item; >> return true; >> } >> } >> ]]> >> </mx:Script> >> >> <mx:ArrayCollection id="arrColl" /> >> <mx:ArrayCollection id="dedupedArrColl" /> >> >> <mx:HBox> >> <mx:VBox> >> <mx:Label text="Original ({arrColl.length} items):" /> >> <mx:List dataProvider="{arrColl}" /> >> </mx:VBox> >> <mx:VBox> >> <mx:Label text="Filtered ({dedupedArrColl.length} >> items):" /> >> <mx:List dataProvider="{dedupedArrColl}" /> >> </mx:VBox> >> </mx:HBox> >> >> </mx:Application> >> >> <!-- End Code --> >> >> On Dec 30 2009, 10:46 am, Kiran Kumar Vasireddy <[email protected]> >> wrote: >> > Thanks Safi for your response . If I do this I get duplicate elements in >> > Mycombox , I want to avoid them. >> > >> > Regards >> > Kiran >> > >> > >> > >> > On Sun, Dec 27, 2009 at 10:50 PM, saanaa safi <[email protected]> >> wrote: >> > > hi kiran, >> > > i hope below example will help u. try this,i think this is what u r >> > > expecting. >> > >> > > <?xml version="1.0" encoding="utf-8"?> >> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >> > > layout="absolute"> >> > > <mx:ArrayCollection id="myColl"> >> > >> > > <mx:Object Company="GM" count="85" Model ="Saab" >> ModelCount="20" >> > > Year="2009" YearCount="10" /> >> > > <mx:Object Company="GM" count="85" Model ="Saab" >> ModelCount="20" >> > > Year="2008" YearCount="5" /> >> > > <mx:Object Company="GM" count="85" Model ="Saab" >> ModelCount="20" >> > > Year="2007" YearCount="5" /> >> > > <mx:Object Company="GM" count="85" Model ="Chevi" >> > > ModelCount="20" Year="2009" YearCount="20" /> >> > >> > > <mx:Object Company="FORD" count="43" Model ="Focus" >> > > ModelCount="20" Year="2009" YearCount="5" /> >> > > <mx:Object Company="FORD" count="43" Model ="Focus" >> > > ModelCount="20" Year="2008" YearCount="3" /> >> > > <mx:Object Company="FORD" count="43" Model ="Focs" >> > > ModelCount="20" Year="2007" YearCount="2" /> >> > >> > > </mx:ArrayCollection> >> > > <mx:ComboBox prompt="Company" dataProvider="{myColl}" >> > > labelField="Company" x="44" y="21" width="100"/> >> > > <mx:ComboBox prompt="Model" dataProvider="{myColl}" >> labelField="Model" >> > > x="153" y="21" width="100"/> >> > > <mx:ComboBox prompt="Year" dataProvider="{myColl}" >> labelField="Year" >> > > x="275" y="21" width="100"/> >> > >> > > </mx:Application> >> > >> > > On Sat, Dec 26, 2009 at 4:00 PM, Kiran Kumar Vasireddy < >> > > [email protected]> wrote: >> > >> > >> Dear All, >> > >> > >> I am getting the data in following format . Is there any way to load >> it >> > >> into comboxbox avoiding duplicates? First combobox I want to just >> load >> > >> Company Name removing duplicates.Second combox box based on the >> section I >> > >> have to load Models and In the Thrid combox box based on company and >> Model >> > >> I have to load Years.Or if not Arraycollection , I can also get the >> data in >> > >> XMLCollection . Could some body please give me best solution? >> > >> > >> <ArrayCollection> >> > >> > >> <mx:Object Company="GM" count="85" Model ='Saab" >> ModelCount=20 >> > >> Year="2009" YearCount="10" /> >> > >> <mx:Object Company="GM" count="85" Model ='Saab" >> ModelCount=20 >> > >> Year="2008" YearCount="5" /> >> > >> <mx:Object Company="GM" count="85" Model ='Saab" >> ModelCount=20 >> > >> Year="2007" YearCount="5" /> >> > >> <mx:Object Company="GM" count="85" Model ='Chevi" >> > >> ModelCount=20 Year="2009" YearCount="20" /> >> > >> > >> <mx:Object Company="FORD" count="43" Model ='Focus" >> > >> ModelCount=10 Year="2009" YearCount="5" /> >> > >> <mx:Object Company="FORD" count="43" Model ='Focus" >> > >> ModelCount=10 Year="2008" YearCount="3" /> >> > >> <mx:Object Company="FORD" count="43" Model ='Focs" >> > >> ModelCount=10 Year="2007" YearCount="2" /> >> > >> > >> </ArrayCollection> >> > >> > >> -- >> > >> You received this message because you are subscribed to the Google >> Groups >> > >> "Flex India Community" group. >> > >> To post to this group, send email to [email protected]. >> > >> To unsubscribe from this group, send email to >> > >> [email protected]<flex_india%[email protected]> >> <flex_india%2bunsubscr...@googlegrou ps.com> >> > >> . >> > >> For more options, visit this group at >> > >>http://groups.google.com/group/flex_india?hl=en. >> > >> > > -- >> > > Warm Regards >> > > Saanaa.... >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups >> > > "Flex India Community" group. >> > > To post to this group, send email to [email protected]. >> > > To unsubscribe from this group, send email to >> > > [email protected]<flex_india%[email protected]> >> <flex_india%2bunsubscr...@googlegrou ps.com> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/flex_india?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Flex India Community" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<flex_india%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/flex_india?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Flex India Community" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<flex_india%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/flex_india?hl=en. > -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

