How to build a collection ArrayCollection with distinct values of an XMLListCollection?

Hello, I'm really bad with what seems like it should be a very simple task. I have a XML of course object which consists of only the names of course. I just want to create a new collection of ArrayCollection which consists of only the names of DISTINCT/UNIQUE course in the XML list to use in a combobox control. I tried all sorts of things but nothing I try seems to work. I have a few listed below MXML.

Any help would be appreciated! Should be simple im sure, and once I understood that, it will make my app built much easier! The value of myDistinctData is the final ArrayCollection collection. For simplicity, I left my attempts failed the loop foreach. THANKS TO ANYONE WHO CAN OFFER HELP!

MXML CODE:

<? XML version = "1.0" encoding = "utf-8"? >
"" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "horizontal" initialize = "GB (); ">

< mx:Script >

<! [CDATA]
Import mx.collections.ArrayCollection;

[Bindable]
public var myDataDistinct:ArrayCollection

public void go (): void {}

var myData:XML =

< course >
< course cid = "1" >
< name > course 1 < / name >
< / course >
< course cid = "2" >
< name > course 1 < / name >
< / course >
< course cid = "3" >
< name > course 2 < / name >
< / course >
< course cid = "4" >
< name > course 3 < / name >
< / course >
< course cid = "5" >
< name > course 1 < / name >
< / course >
< course cid = "6" >
< name > course 3 < / name >
< / course >
< / course >;

for each {(thisCourse:XML var in myData)

-SOME CODE THAT CREATES A TABLE OF DISTINCT VALUES GOING HERE?
}
}
[]] >

< / mx:Script >

< mx:Label text = "names of separate courses:" / > ""
< mx:ComboBox dataProvider = labelField "{myDataDistinct}" = "" / >

< / mx:Application >


I don't know how to remove duplicates in an ArrayCollection collection or otherwise.
But since you already have an XML and require only a text node inside.
I go through the easiest way.

Please take a look


http://www.Adobe.com/2006/mxml"layout ="horizontal"initialize ="GB (); » >

Import mx.collections.ArrayCollection;

[Bindable]
public var myDataDistinct:ArrayCollection

public void go (): void {}

var myData:XML =

Course 1


Course 1


Course 2


Course 3


Course 1


Course 3

;

you need to do collection here ArrayCollection instance before put something u.
this.myDataDistinct = new ArrayCollection();

E4X selection
var xmlList:XMLList = myData.course.name;

for each (var xml in xmlList)
{
trace (XML); you will see that we have now.
var str:String = new String (xml);
var flag: Boolean = true;
for (var i: Number = 0; i
{
If (this.myDataDistinct.getItemAt (i) == STR)
{
flag = false;
break;
}
}
if(flag==true) {This.myDataDistinct.AddItem (STR) ;}
}
}
]]>



Tags: Flex

Similar Questions

  • How to build the file manager with cascade?

    Guy of Halo,

    How can IM new with waterfall, I build a file manager with cascade? is there a lesson or sample

    Thank you

    concerning

    Hello

    Can you clarify a little more what you mean by FileManager? Do you want the opportunity to browse and select files? If so, take a look at this thread. http://supportforums.BlackBerry.com/T5/Cascades-development/using-native-FileBrowse-and-FileSave-dia...

    See you soon

    Swann

  • How to browse the collection ArrayCollection?

    I have two datagrids and you want to move items on datagrip and fill the other.  Here is a screenshot of a Visual screen.

    Picture 1.png

    In the screenshot on I can add some names/sex to the datagrid on the left using the text input and the Add button.  I can select the checkboxes for each name of ros as well. I want to do is move the check names in the datagrid control on the left for the datagrid on the right.  4 max.  But if I chose only 2 name, both names would be added to the 1 Racer and Racer 2. Runner 3 and 4 of the race would be left blank.  If I check the new names and submitted it would be in a new line on the left data grid.

    What I can understand is to scroll the datagrid control left and find only the lines of control.  To the right of the datagrid can be quite easily as soon as I figure out how to identify what is checked and what is not checked.

    This is the datagrid on the right.

    "" " < mx:DataGrid x ="10"y ="76"height ="337"id ="list"editable ="false"dataProvider =" rosterArray{}">

    < mx:columns >

    < mx:DataGridColumn headerText = "" width ="30">

    < mx:itemRenderer >

    < mx:Component >

    < mx:CheckBox / >

    < / mx:Component >

    < / mx:itemRenderer >

    < / mx:DataGridColumn >

    "" < mx:DataGridColumn headerText = "name" dataField ="name" width = "200" "editable ="false" / >

    "" < mx:DataGridColumn headerText = "sex" dataField ="sex" width = "40" "editable ="false" / >

    "" < mx:DataGridColumn headerText = "time" dataField ="time" width = "45" editable ="false" / >

    < / mx:columns >

    < / mx:DataGrid >

    The function add to my rosterArray (left datagrid) is below.

    private function rosterAdd():void

    {

    rosterArray.addItem({name:addName.text,sex:sexGroup.selectedValue.toString()});)

    addName.text = ""; empty text entry field.

    }

    I guess I have to scroll datagrid and not the rosterArray because I don't have a place for the checkmarks in the rosterArray.

    Any help idetifying which lines are checked in the left data grid would be much appreciated.

    Thank you.

    This code is not production level, but it should answer your question.

    If this post answers your question or assistance, please mark it as such.

    Greg Lafrance - Flex 2 and 3 certified ACE

    www.ChikaraDev.com

    Flex / development, training, AIR and Support Services

    
    
      
        
      
      
      
        
          
          
            
            
            
            
          
          
            
              
                
                  
                    
                      
                        
                          
                        
                      
                    
                  
                
              
              
              
              
            
          
          
        
        
          
          
            
              
              
              
              
            
          
          
        
      
    
    
  • OPV with distinct values for the guests

    Hi all

    Could you get it someone please let me know where/what I'm wrong. I created the couple of OPV to get distinct values, as I can't use the view that has millions of data to load guests.

    These OPV is not directly attached to my main table but joined someother tables; After you add the guests in the responses, is to show the below error

    [nQSError: 14070] can't find coverage source logical table to the columns of the logic: [bp Manager]. Please check more detailed level keys are correctly mapped. (HY000)

    I wan to the OPV use only for guests and pass the values to help requested on the main table filters

    I have no warnings/errors in my model. What could be the problem? Thank you for your time

    REDA

    Just go with PSV.

    Check it cool - bi.com for "what happens when we select all the column values.

    Table x got to join the only 1OPV then how can you expect comes from BI to the other 2 open-pollinated varieties? Likewise, we cannot write query!

    If you can create a domain for each OPV then proceed with a command prompt with the UNION of 3 open-pollinated varieties clause

  • How to check the page dirty with default values existing in viewObject?

    Hi all

    I use JDeveloper 11.1.1.4.

    I have two pages in my application. I am browsing for page2 page1.

    Before opening page 2 I created new line page 2 notice of object using method 'Create Insert()' with some default values by using the ViewRowImpl class.

    My problem is that I have a button to return to Page 2. If I click the back button, then check the Application module is dirty or not.

    But it always shows AM is dirty due to I'm setting some default values in ViewRowImpl. If I avoid the default values in ViewRowImpl then AM dirty check works fine.

    My Question is how to check the AM (or) dirty Page with default values in the object view?

    My bean Codes:

    Links DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();

    DataControl dc = bindings.findDataControl("AppModuleDataControl");

    ApplicationModuleImpl am = ((ApplicationModuleImpl) dc.getDataProvider ());

    If (am.getDBTransaction (.isDirty (()))

    {

    return "Page is dirty."

    }

    My Jspx Codes:

    < af:commandLink id = "cl6" text = '2 '.
    shortDesc = "Add Row in Page2"
    actionListener = "#{bindings." Action CreateInsert.execute}' = 'Edit' >

    Thank you

    David...

    see this

    http://www.techartifact.com/blogs/2013/11/how-to-check-ifdirty-is-modified-for-view-object.html

    http://www.jobinesh.com/2011/05/checking-for-dirty-data.html

  • How to capture the time entry with the value 'default' as SYSDATE

    Hello

    I created "entry receipt" form by using wizard.

    Hidden CREATED_ON column is defined with the value 'default' as SYSDATE.

    However, it's only complete part of date, but time is not included when I discovered that in the report.

    Format under 'source' mask is defined as "MON-DD-YYYY HH24:MI:SS" during form entry.

    Under the column definition format mask is "HH24:MI:SS MON-DD-YYYY" under the report.

    Need help to fix this problem.

    I use APEX worm 4.2.6

    Thank you

    -Anand

    Is it viable to not include the column in the form of the APEX and have a default value to the column in the table?

    ALTER table my_table change created_on default sysdate;

  • How to build for armv6, not with Flash Pro 5.5 armv7? Help!

    I built an update for my application, first built with Flash 5 Pro and I've updated to Flash Pro 5.5, and now Apple tell me the app must be armv6, armv7 not

    I don't see any way to tell the publication settings for armv6?

    Thank you

    Robert

    A 3G iPhone is a device armv6 and apps packed with AIR 2.6/2.7 does not work on it.

  • Concatenate columns with distinct values from oracle

    Hello gurus,

    My gaze of structure of table as follows:

    TankListUS TankListCanada TankListIndia

    ----------           --------------              -------------

    T111 | T222 T444 | T222 T555

    Now when I run the query:

    Select (TL. TankListUS | '||'  || WLM TankListCanada | '||'  || WLM TankListIndia) as "OverallSummary" of TankListTL

    I get the output voltage

    T111 | T222 | T444 | T222 | T555

    But I do not need to duplicate tanks. I need my output like:

    T111 | T222 | T444 | T555

    Is this possible?

    Hello

    Try this

    with t1 as (select ' T111 | ") T222 | T444 | T222 | T555' double collar).

    T2 as (SELECT rownum, REGEXP_SUBSTR (col, ' [^ |] +', 1, RN) SPLIT)

    from t1

    cross join

    (SELECT ROWNUM RN

    FROM (SELECT (length (REGEXP_REPLACE (col, ' [^ |] +')) / 2) + 1 MAX_VALUE)

    from t1)

    connect by level<=>

    T3 as (select distinct split as the t2 dis_col)

    Select

    RTrim (xmlagg (xmlelement (e, dis_col |))) '||')). extract ('/ / text()'), ' |') d_col

    Of

    T3;

    Kind regards

    Mohan.

  • How to return a single LINE with Multiple value separated by a colon in a SQL query

    Hello

    I have a SQL, as shown.
    select deptno
      from dept
    I want to mofidfy this query, so that it should return me departments with colon delimeted list in a ROW.
    10:20:30:40.......
    Thank you
    Deepak
  • Clever bulk collect work with 9.2 and snaps.

    Hello
    I do shots of v$ sysstat with 1 delay seconds to count things like this:
    select name,value from v$sysstat
    where
    name in ('execute count', 'parse count (hard)', 'parse count (total)',
                              'physical read total IO requests', 'physical read total bytes',
                              'physical write total IO requests', 'physical write total bytes',
                              'redo size', 'redo writes', 'session cursor cache hits',
                              'session logical reads', 'user calls', 'user commits') ;
    dbms_lock.sleep(1);
    
    select name,value from v$sysstat
    where
    name in ('execute count', 'parse count (hard)', 'parse count (total)',
                              'physical read total IO requests', 'physical read total bytes',
                              'physical write total IO requests', 'physical write total bytes',
                              'redo size', 'redo writes', 'session cursor cache hits',
                              'session logical reads', 'user calls', 'user commits') ;
    But Im really interested in the deltas, so think, perhaps in bulk to collect is the obvious solution.
    I can work around that, with the achievement of pivot and self, sign up to get only 1 line per request and then just do the math.
    Wondering how to build the collection in support of my application?
    Code should work on 9.2 and above.
    Concerning
    GregG

    GregG says:
    OK, but how do you know which session should be monitored?
    You use over connection therefor triggers and trigger disconnect to end sampling?
    Looks like an overhead projector for me.

    As Padders said, it must be activated when necessary. I've never used triggers still allow - but it can be done via connect/disconnect session if necessary triggers.

    Keep in mind that the SQL Statistics is not always one. Often, you need to enable these manually, according to the database by default, the version, and requirements. For example

    alter session set statistics_level = all
    alter session set timed_statistics = true
    alter session set timed_os_statistics = 5
    

    Alternatively, you can manually set the trace level.

    Point being is that you have a package with the following basic interface:

    create or replace package FooStats as
      --// instruct stats/tracing to be enabled and base snapshot
      --// of current stats to be taken (stored in GTTs)
      procedure StartSnapshot( processName varchar2, .. );
    
      --// instructs the GTT base data to be updated with the delta between
      --// the base data and current stats data
      procedure EndSnapshot( .. );
    
    end;
    

    .. turn stats recording on and outside, quite easy. It can prepare the database session to stats followed, set trace levels, issue commands alter session and so on.

    It allows for example to define a normal application with global Boolean static process which can be activated to indicate that the module app to instrument himself by saving his stats processing, using your custom statistics package.

    However, you choose to do it well, the basics of modularization and re-use remain key.

  • "How to build a reusable toolbar...". "does not.

    I tried to run this suggested in the corner of code document "how to build a reusable tools with Oracle ADF declarative components toolbar".
    I created the toolbar and deployed.
    I have inserted the pot in my project and create a new page.
    I've included the toolbar and hanging methods to the link of the page.
    When I run the page I see the boolbar as well as the data in the table, however, when I click on the button, that nothing has changed (the location of the selection remains unchanged).
    I missed something?
    Should I set a partial trigger?
    TKS
    Tullio

    When you create the declarative element, you now define an attribute and call it something like DataSet (of type String).

    In the declarative component, select the button and for its property TEXT put something like ' next #{uploading. '. DataSet}"- without the quotes.

    This will define that button to show following PGE label if you value DataSet Emp when you use the declarative component.

    So, now you repapckage upward and deploy the library of the ADF and now when you use the component, you can set the DataSet attribute (in the property inspector when you select the instance of the declarative component).

    Hope this helps

    Grant

  • Problem with allocating memory collection arraycollection by AddItem

    I have a strange problem with the AddItem method.

    I made a new item with this code:

    ------

    for (var u: int = 0; u < 41; u ++) {}
    Page = new PageToSave();
    project.addPage (page as PageToSave);
    }

    -----

    the project is a distance of class projectblueprint:

    package marcoDoItBetter.utils
    {
    Import mx.collections.ArrayCollection;
    public class ProjectBlueprint
    {
    private var _pages:ArrayCollection;

    public void addPage(page:PageToSave):void
    {
    This._pages. AddItem (page);
    }

    }

    }

    ----

    PageToSave is a class that extends the object.

    When we create the element using the addPages (so with in the collection _pages arraycollection's addItem) programmatically, we have this result using the term Inspector in debug mode.

    It is on the output of the debugger:

    pageList = mx.collections.ArrayCollection (@105cf341)
    [inherited] =
    [0] = marcoDoItBetter.utils.PageToSave (@113cb461)
    [1] = marcoDoItBetter.utils.PageToSave (@113cb401)
    [2] = marcoDoItBetter.utils.PageToSave (@113cb3a1)
    [3] = marcoDoItBetter.utils.PageToSave (@113cb341)
    [4] = marcoDoItBetter.utils.PageToSave (@113cb2e1)
    [5] = marcoDoItBetter.utils.PageToSave (@113cb281) < -.
    [6] = marcoDoItBetter.utils.PageToSave (@113cb221)
    [7] = marcoDoItBetter.utils.PageToSave (@113cb1c1)
    [8] = marcoDoItBetter.utils.PageToSave (@113cb161)
    [9] = marcoDoItBetter.utils.PageToSave (@113cb101)
    [10] = marcoDoItBetter.utils.PageToSave (@113cb0a1)
    [11] = marcoDoItBetter.utils.PageToSave (@113cb041)
    [12] = marcoDoItBetter.utils.PageToSave (@1140dfa1)
    [13] = marcoDoItBetter.utils.PageToSave (@1140df41)
    [14] = marcoDoItBetter.utils.PageToSave (@1140dee1)
    [15] = marcoDoItBetter.utils.PageToSave (@1140de81)
    [16] = marcoDoItBetter.utils.PageToSave (@1140de21)
    [17] = marcoDoItBetter.utils.PageToSave (@1140ddc1)
    [18] = marcoDoItBetter.utils.PageToSave (@1140dd61)
    [19] = marcoDoItBetter.utils.PageToSave (@1140dd01)
    [20] = marcoDoItBetter.utils.PageToSave (@1140dca1)
    [21] = marcoDoItBetter.utils.PageToSave (@1140dc41)
    [22] = marcoDoItBetter.utils.PageToSave (@113cb281) < -.
    [23] = marcoDoItBetter.utils.PageToSave (@1140db81)
    [24] = marcoDoItBetter.utils.PageToSave (@1140db21)
    [25] = marcoDoItBetter.utils.PageToSave (@1140dac1)
    [26] = marcoDoItBetter.utils.PageToSave (@1140da61)
    [27] = marcoDoItBetter.utils.PageToSave (@1140da01)
    [28] = marcoDoItBetter.utils.PageToSave (@1140d9a1)
    [29] = marcoDoItBetter.utils.PageToSave (@1140 d 941)
    [30] = marcoDoItBetter.utils.PageToSave (@1140d8e1)
    [31] = marcoDoItBetter.utils.PageToSave (@1140 d 881)
    [32] = marcoDoItBetter.utils.PageToSave (@1140 d 821)
    [33] = marcoDoItBetter.utils.PageToSave (@1140d7c1)
    [34] = marcoDoItBetter.utils.PageToSave (@1140 d 761)
    [35] = marcoDoItBetter.utils.PageToSave (@1140 d 701)
    [36] = marcoDoItBetter.utils.PageToSave (@1140d6a1)
    [37] = marcoDoItBetter.utils.PageToSave (@1140 d 641)
    [38] = marcoDoItBetter.utils.PageToSave (@1140 d 221)
    [39] = marcoDoItBetter.utils.PageToSave (@1140d5e1)
    [40] = marcoDoItBetter.utils.PageToSave (@1140 d 461)
    source = Array (@1140c9a9)

    as you can see the [5] and the [22] PageToSave id internal flex (or instances of the class has the same address listing.

    "I don't know the exact name of it). It happens totally randomly.

    sometimes fine, sometimes there's more than a duplicate with random address referencing the game.

    I don't want duplicated instances, but I want independent authorities.

    I tried to change addItem with

    This._pages.addItemAt (page, 0);

    Same result.

    I also tried pagina = null before the statement new but same result

    ------

    for (var u: int = 0; u < 41; u ++) {}
    Page = new PageToSave();
    project.addPage (page as PageToSave);

    Page = null;
    }

    -----

    is a garbage collector from?

    How can we solve this problem?

    Thank you

    Hello

    From the looks of it, looks like a bug.

    Are you defining filters or performs a sort on the ArrayCollection collection? Or it's just a pure naked collection instance ArrayCollection.

    Have you tried addItemAt() and got the same result?

    Mike

  • Display collection ArrayCollection in a list and the ArrayCollection with Drag and Drop collection reorgnize

    I have an ArrayCollection collection created like this

    qaAC = new ArrayCollection();

    for (var i: int = 0; i < 10; ++ i) {}
    var o: Object = {question: ' what is "+ i +"? ", answer:" it's "+ i"};
    qaAC.addItem (o);
    }

    The ArrayCollection collection is an array of object that has properties "question" and "answer to" custimized.

    I want to put 'issues' in the ArrayCollection collection in a list. 'qaAC.question' does not return an array of questions for me.

    I have to extract the ArrayCollection collection to form a new String table, and use the new array as the dataProvider of the list of questions.

    Is there a way better and clean?

    My goal is to use a list to reorgnize an ArrayCollection collection that contains complex objects (not simple string) with Drag & Drop. Is this possible?

    Any suggestions?

    I put two lists in my example to show how the ArrayCollection collection could be displayed in two different ways. You don't have to have two lists if you do not need them.

    When you change the order of the list made with drag and drop, you change the order of the collection ArrayCollection qaAC, so all the controls that display the qaAC will also be updated to reflect the new order. You can test this in the example I posted earlier. Change the order in the list of question and you will see the order change also in the list of responses. This is because they are both bound to the same collection of ArrayCollection. If you want to behave independently, you need two separate ArrayCollections.

    Chris

  • How to loop through DataGrid (ArrayCollection, DataProvider collection)

    I need to loop through a collection ArrayCollection DataProvider or DataGrid (not sure which is best) so that I can insert information in a database through ColdFusion.

    The data grid has three columns: ID, item and quantity.  I have a table that contains these same fields.  The DataGrid control is pre-filled with a list of items.  The user can then enter the quantity of items in the DataGrid.  I then want to store this information in my table.  In ColdFusion, I would accomplish this through CFLOOP, however, in Flex I want to loop through the data grid so that I can get all the items and the quantities that the user has updated.

    I guess I have to do a loop in ActionScript, but I don't know how to do that.  Can anyone provide a suggestion and example code?

    Thanks again!

    Lee

    If this post answers your question or assistance, please mark it as such.

    Here ya go:



    http://www.Adobe.com/2006/mxml '.
    creationComplete = "init (); » >
     
        Import mx.collections.ArrayCollection;
         
    public void init (): void {}
    var ac:ArrayCollection = new ArrayCollection([)
    {Field1: "my one - item a field", Field2: "my field two - point one"},
    {Field1: "my field one - point two", Field2: "my field two - point two"},
    {Field1: "my one - three field element", Field2: "my field two - point three"},
    ]);
    for each {(var point: Object en ac)}
    for each {(var: objet field àle point)}
    trace (Field);
    }
    }
    }
    ]]>
     

  • Help!  How to upgrade two dimension collection ArrayCollection?

    Hello

    I'm having a problem of understanding of documentation on populating a DataGrid of two dimension collection ArrayCollection. My situation is that I have a DataGrid with a bunch of information, currently stored in a two-dimensional array (digital in the first dimension and by field name in the second dimension). I also have a bunch of data streaming from an XMLSocket, which, when it happens, is analyzed, resulting in one of the fields of the table in need of update. I can do very well with the table directly, but I can't try to understand how use the ArrayCollection collection features to cross this two-dimensional structure - setItemAt() does not seem suited for this purpose? I need to trigger the effects on the relevant cell that has been updated, when I round coding, so I will try to use some structure that handles update events and others for me automatically, such as the ArrayCollection collection.

    I do not know is still the best technique to use, and the intermediate level (the ArrayCollection collection and others) could be changed completely, so if you can suggest (and illustrate, if she is as confused as this!) a better method, I would be grateful.

    Thank you

    David

    Ah.

    You must look for the item in the collection ArrayCollection. This is usually done with a loop in the collection. When you have found the item you would:

    Item.Quantity = new quantity;
    dp.itemUpdated (item);

    You must call the method of collection itemUpdated to make the signal Collection all interested parties (for example, the DataGrid bound to her) she's changed.

    A Collection can also views and ViewCursors that might be useful to have a lot of data.

Maybe you are looking for