--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.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 flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.
Here is the code (visit the website link above to see a working
example)
<!-- Start Code -->
<?xml version="1.0" encoding="utf-8"?>
<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 <kiranv...@gmail.com>
wrote:
> >> flex_india+...@googlegroups.com<flex_india%2Bunsubscribe@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 flex_...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > flex_india+...@googlegroups.com<flex_india%2Bunsubscribe@googlegrou ps.com>
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
First create six array collections for six comboboxes which will be
data providers for them. I am assuming that there can be change in the
collection (sourceCollection) e.g. add/remove etc in mean time and you
would like to reflect that too. So first add an event listener on that
collecion like:
sourceCollection.addEventListener(CollectionEvent.COLLECTION_CHANGE,
collectionDataChanged);
Then in that case a fucntion collectionDataChanged will be called
upon.In that function if change is collection.refresh dont do
anything, else update individual combobox data providers:
updateOrganizationDataProvider(organizationCollection,
newOrganization)
updateModelDataProvider()
so on.....
updateOrganizationDataProvider(ac:ArrayColleciton, obj:object)
{
if (ac.contains(obj)
return
esle
ac.add(obj)
}
for other comboboxes addition/deletion will be done same way but that
will depend upon selection in previous comboboxes. Also FIlter
function can be written keeping in mind the selections in all
comboboxes.
I hope it helps.
companyAC, ModelAC,
<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" />
On Jan 22, 5:02 pm, Varun Bajaj <vb.j...@gmail.com> wrote:
> 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 <
>
>
>
> warriorofheavens...@gmail.com> wrote:
> > Read about filter function it will be quite helpful.
>
> > On Fri, Jan 22, 2010 at 4:39 AM, Aviral Sharma <aviralmsha...@gmail.com>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...
>
> >> 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...
> >http://groups.google.com/group/flex_india?hl=en.- Hide quoted text -
>
> - Show quoted text -