Access table in the arraycollection collection and add the item at the end of the table

for


"login_user":"XXX"},i);

//mess2=sess_MessArr[i2];
//mess1=dispArray[i2].fwchat_message

//searchArray(mess2);}





(var i:int = 0; i< dispArray.length; ++i){

dispArray[i]. 
dispArray.addItemAt({


I have this code to try to access the values in the table in the arraycollection collection, but that's not it actually creates a value at the end of the arraycollection collection. can someone tell me what im doing wrong I basically want retransmits the individual tables in the arraycollection collection and add Login_user

So, I guess your ArrayCollection collection holds an array of objects, as follows:

public var myAC:ArrayCollection = new ArrayCollection([{first:"bob",last:"smith"},{first:"jim",last:"jones"},{first:"mary",last:"allen"}]);

And you try to add a new property of login_user to each of them, right?

for each (var obj:Object in myAC) {
     obj.login_user = obj.first + "83";
}

Each person would be firstly, properties last and login_user.  In my example above, all the login_user would set their name + number 83, so adjust you accordingly for your application.

It is the ease (for each rock for this situation).  However, if you want to paste the iterative approach, you have published, you can try this:

for (var i:int = 0; i < myAC.length; i++) {
     myAC.getItemAt(i).login_user = myAC.getItemAt(i).first + "83";
}

I think that the for each syntax is clearer, but anyway works the way I think you want.

Tags: Flex

Similar Questions

  • Export the ArrayCollection collection in XML file

    Hi all

    Is it possible to export a Flex ArrayCollection collection to an XML file.

    My collection of table is displayed in a datagrid as follows

    < mx:DataGrid = "360" x y = "120" width = "448" height = "200" dataProvider = "{questionsArr}" >
    < mx:columns >
    < mx:DataGridColumn headerText = "Issue" dataField = "issue" / >
    < mx:DataGridColumn headerText = dataField "Start" = "start" width = "40" textAlign = "center" / >
    < mx:DataGridColumn headerText = "Stop" dataField = "stop" width = "40" textAlign = "center" / >
    < / mx:columns >
    < / mx:DataGrid >

    And I want to output the XML to look like this

    < cue >
    "< question section =" "start =" "stop =" "/ >
    "< question section =" "start =" "stop =" "/ >
    "< question section =" "start =" "stop =" "/ >
    < / cue >

    Is this possible?  I mean all the data is ready, he just needs to be saved. .

    Hi djh88ukwb,

    Try something as shown below in the link by performing a loop through the arraycollection collection and forming the knots... the way you need...

    http://nsdevaraj.WordPress.com/2008/08/20/ArrayCollection-XML/

    Thank you

    Jean Claude Chari

  • Condition in the ArrayCollection collection

    I have an ASP application that retrieves the files form a MS SQL Server db.

    My flex application the user can select the desired file to download. It search the name of the file as it is written in my flex application which is worng because the actual name in the SQL Server db is different.

    So now I'm trying to solve this problem with an ArrayCollection collection that has the file name time as Flex knows it and the name of the SQL Server.

    var sdeName:ArrayCollection = new ArrayCollection([)
    {label: "labelInFlexApp", data: 'labelInSQL'}
    ]);

    If (sdeName [label] == item.label) {}
    Item.label = sdeName [data];
    var url: String = " " http://Server/getMetaData/metadata.aspx?sdeFeatName= " "+ item.label +"&"+"outFormat = ISO";

    }

    I do not know how to find the value in my ArrayCollection collection and compare it with the real one.

    Thank you

    Manolo

    Hello

    Try:

    if (sdeName.getItemAt(i)["label"] == item.label) {
    

    Instead of:

    if (sdeName.getItemAt(i).[label] == item.label){
    
  • Summary of the ArrayCollection collection

    Hello!
    I tried to see if there is a way to create summary with the grouping columns data so that summary data can be used with other than AdvancedDataGrid components (such as graphics, etc.). I have flat (about 5 rows of K with 20 columns) data in an ArrayCollection collection and need to cut out the data about five different ways for graphics.
    I could do it manually while browsing the collection (or get the data aggregated from BlazeDS service sets), but I was wondering if there is a function that can be used for grouping.
    I don't know that if it's a good one to do what would be the aggregation on the client (I feel it takes too long) - I'd be better to get the data aggregated from the server?

    Thank you
    RAM

    "rsarma" wrote in message
    News:gg2eqg$H15$1@forums. Macromedia.com...
    > Hi!
    > I tried to see if there is a way to create summary data with
    > grouping columns so that summary data can be used with components
    > other
    > than AdvancedDataGrid (like graphics etc.). I have flat data (about 5 K lines
    > with
    > 20 columns) in an ArrayCollection collection and the need to cut about five data
    > differently for graphics.
    > I could manually do iteration in the collection (or get
    (> the datasets in BlazeDS service aggregated) but I was wondering if it
    > is a
    > existing function that can be used for grouping.
    > I don't know yet if it's a good to do all aggregation on the client
    > (i
    (> have a feeling that it will take too long)-I'd better get the
    > data aggregated from the server?

    You can use GroupingCollections as you want. I only did the summary lines,
    but check out this example:
    http://flexdiary.blogspot.com/2008/09/GroupingCollection-example-featuring.html

  • Object to an ArrayCollection collection

    Hello

    I have an application that supports some info from database and he sinks into a datagrid, or a chart.

    I met this error to have one line and try to use it in a table so that I can use in my application.  Its come to my attention that it is a quite common problem that people face, but I don't seem to be able to get around any one test.

    My actionscript has a function that trots through ASP database and returns the data in the case - as below (obv I deleted stuff - load of calls are made to the mssqlQuery function - the only one I have trauma with is below)

    mssqlQuery ("SELECT (CASE SLARag, COUNT (SLARag) as Volume [CMI_ClientMI]. [Portal]. [BatchUpdate]","BusSegBuildSummary") ;}

    public static void mssqlQuery(sql:String,fid:String):void {}

    var http:HTTPService = new HTTPService;

    var parm:Object = new Object;

    parm.fas_sql = sql;

    parm.fas_db = mssql_db;

    http.url = mssql_url + "? irand =" + Math.random ();

    http.showBusyCursor = true;

    http.request = sql;

    http.addEventListener (ResultEvent.RESULT, mssqlResult);

    http.addEventListener (FaultEvent.FAULT, mssqlFault);

    http.method = "POST";

    sqlToken = http.send (parm);

    sqlToken.param = fid;

    }

    For BusSegBuildSummary collection arraycollection var

    [Bindable]

    public static var _BusSegBuildSummary:ArrayCollection = new ArrayCollection();


      

    Case statement to BusSegBuildSummary

    case 'BusSegBuildSummary':

      


    If (event.result.results.record is ObjectProxy) {}

    trace ("this is a Proxy object");


    }

    else {}

    trace ("it isn't Proxy object");

    _BusSegBuildSummary = event.result.results.record;

    }

    break;

    So - if the result has several records in it - so we are very well - it's the trace ("this is Proxy object"); bit which is annoying.

    I think I have to send the object as an arraycollection collection and I tried a number of different ways without success.

    Any ideas? I struggled for a while now and I am panicing!

    Hi Andrew

    No problem with the warranty so I wanted just report to disseminate good practices

    I do not understand what you write, but it is how I read it:

    When the user runs the function again, you get a more added slice, you can don't wan't, only you don't wan't the new?

    This is because you don't collection.addItem (item), so just add the to it to the collection.

    If you need to do:

    If (event.result.results.record is ObjectProxy)

    {

    collection.removeAll ();

    collection.addItem (event.result.results.record)

    }

    Best regards

    Martin

  • How can I convert an arraycollection collection put an XmlList as a dataprovider for ADG

    I have an arraycollection collection that I get from the backend. I need to convert XMLList with knots, because I need to show data such as the branches of the ADG.

    now I use grouping but get a lot of sorting problems. So I want to convert XmlList to show the data as it is.

    is it possible to manage this problem?

    Example of sample can be enjoyed.

    Fasten your arraycollection collection and create your own xml file.

    var arr:ArrayCollection = your arraycollection;
    var xml:XML = ;
    
    for each( var i:Object in arr ){
         xml.appendChild(  {i.value}  );
    
    }
    
    var xmlCLT = new XMLListCollection( xml..node );
    

    Or you can put code in the itemrenderer to analyze the property data, so you can use your arraycollection collection directly.

  • To access the names of the fields in the ArrayCollection collection

    Hello, this can seem like a n00b question, but, I have a collection of table that looks to the below:

    public var topFive:ArrayCollection = new ArrayCollection([)
    {Month: "GAME_Redemptions"},
    {Month: "TALLINK_Redemptions"},
    {Month: "YvesRocher_Redemptions"},
    {Month: "ETAM_Redemptions"}
    ]);

    With a loop, for example, if I want to access the value, I would type, topFive [i] .month. However, if I want to access domain name, what would be the code. IM assuming that it would be something like [i] topFive - but it does not return the desired result.

    Does anyone know how to do this? I wanted to avoid having to put the table in a datagrid control and then extract values from there.

    Help, please!

    Craig

    Your ArrayCollection collection contains five dynamic objects. If the expression 'topFive [i]' will give you the object at index 'i', rather than the Month of this object property. If you do not know the names of the properties of these objects then you need in order to access their properties a second loop:


    <>
    "xmlns:MX ="http://www.adobe.com/2006/mxml"
    Layout = "vertical" >
       
       
            Import mx.collections.ArrayCollection;
               
    private var topFive:ArrayCollection = new ArrayCollection([)
    {Month: "GAME_Redemptions"},
    {Month: "TALLINK_Redemptions"},
    {Month: "YvesRocher_Redemptions"},
    {Month: "ETAM_Redemptions"}
    ]);
               
    private void doLoop(): void
    {

    Loop through the objects in the collection
    for each (var item: object in topFive)
    {

    Loop in the properties of the current object.
    for (var property: String in object)
    {

    Display the name of the current property and the value it contains
    output. Text += property + ":"+ object [property] + '\n'; '.
    }
    }
    }
               
    ]]>
       
       
        <>
    label = 'Do Loop'
    Click = "doLoop ()" / > "
           
        <>
    Width = "200".
    Height = "300".
    ID = "output" / >
       

  • Add the object to the ArrayCollection collection

    Hi all

    I have an ArrayCollection collection which will be filled by a call remotely from java code.

    The Collection is no longer bound to a ComboBox that is shownup in the Panel.

    I tried to add an object to the collection of ArrayCollection iterated to 0th Index, whereas I could see this label of objects as the default label in the drop-down list box.

    But when the drop-down list box is displayed, the first element of the returned list of JavaCode is shown as the default label.

    See all present items in the drop-down list box, the label of objects which is added at Index 0 is seen, but when rendering this is not used as the default when appears on the display.

    < mx:ArrayCollection id = "departments" / >

    private void departmentResultHandler(event:ResultEvent):void
    {
    departments = event.result as ArrayCollection collection;
    Department: Department of var = new Department();
    department.departmentID = 0;
    department.departmentName = "Department";
    departments.addItemAt(department,0);
    }

    < mx:ComboBox id = "add_departmentID" dataProvider = "{services}" labelField = "departmentName" textAlign = "left" selectedIndex = "0" / >

    As I can't download images screeshot here, these are the URL that displays the images and gives a clear picture of what explains

    http://picasaweb.Google.com/narra.Madan/screenshots/photo#5118474206291402818

    http://picasaweb.Google.com/narra.Madan/screenshots/photo#5118474206291402834

    Please suggest where I have gone wrong

    Kind regards
    Madan

    The problem is the timing. When you assign the event.result to departments, the result is bound to the drop-down list, and the first item is selected by default. When new items are added to the drop-down list, flex does not change the selected item to the new item. Yes, it's just saying to your drop-down list box to select the element 0 and it will show Department.

    departments.addItemAt(department,0);
    add_departmentID.SelectedIndex = 0;

    You can also look at the use of the prompt property of the combo box. The prompt when comboBox.selectedIndex = - 1. Unless you need article of the Jet to be selectable, you can quickly define = 'Department' and then do:

    private void departmentResultHandler(event:ResultEvent):void
    {
    departments = event.result as ArrayCollection collection;
    add_departmentID.SelectedIndex = - 1;
    }

    Vygo

  • Add a line of DataGrid using the ArrayCollection collection

    Work of one of these, when I hard code do it programmatically is not:

    Hard-coding approach 1 - *.
    var acData:ArrayCollection = new ArrayCollection();
    ...

    Each DataGridColum has a dataField like "col1", "col2", "col3", etc...
    Therefore, adding items like this works
    acData.addItem({col0:"testa",col1:"testb",col2:"testc",col3:"testd",col4:"teste"});)


    2 - programming approach *.
    But adding items like that does not work
    for (var j = 0; j < dataRows.length (); j ++) {}
    var t:String = [j] of dataRows m:System.NET.SocketAddress.ToString (); dataRows is of type XMLList, data are formatted as the format above
    I did a breakpoint to check and someone else watch the channel and it matches the format that works.
    acData.addItem (t);
    }

    When I try the second approach, I get all the content of the string in each cell of the grid, where, in the first approach, I get "tested" in the first column, "testb" in the second column (without quotes of course), etc...

    Anyone know why there is a difference or what I am doing wrong?

    Thanks in advance.


    I guess that's because in the second approach, you add a string to your ArrayCollection collection instead of an object as in the first approach:

    acData.addItem({col0:"testa",col1:"testb",col2:"testc",col3:"testd",col4:"teste"});) This is an object with the properties that you add to the ArrayCollection collection

    var t:String is dataRows [j] m:System.NET.SocketAddress.ToString ();. It is a string, not an object
    acData.addItem (t); you add a string to the ArrayCollection collection

    You must take your XML string and generate a new object, as in your first approach, using the End Sub

  • Is this really the case with the free player, the clients can access is no longer a PDF to add comments and mark out? We have always used a PDF file for the reviews of books/documents, but now we hear customers that there is no way to add comments and ann

    Is this really the case with the free player, the clients can access is no longer a PDF to add comments and mark out? We have always used a PDF file for the reviews of books/documents, but now we hear customers that there is no way to add comments and annotation. Please let me know if this is the case, or if there is a solution

    '' If '' they use the free software Adobe Reader and "If" there is no security prevent this, he should be able to add comments.

    It'll be hard to say what's wrong without more details such as what exact version of the reader they use, they open the pdf file in a browser or in the player itself and what exactly happens when they try to add comments.

  • Remove duplicates and add to collection totals ArrayCollection

    Is there a function that removes duplicates from a table collection and totals a value where duplicates?

    For example Array

    [Name: John, value: 2]

    [Name: Dave, value: 10]

    [Name: John, value: 2]

    [Name: Dave, value: 8]

    [Name: Dave, value: 2]

    [Name: John, value: 1]

    Output should be:

    Name: John value: 5

    Name: Dave value: 20

    Thank you very much - I really need help with this, I can not logic.

    Thank you

    Please try this,

    private void filterData(event: MouseEvent): void {}
    var source: collection ArrayCollection = new ArrayCollection();
    source.addItem ({name: "John", value: 2});
    source.addItem ({name: "Dave", value: 10});
    source.addItem ({name: "John", value: 2});
    source.addItem ({name: "Dave", value: 8});
    source.addItem ({name: "Dave", value: 2});
    source.addItem ({name: "John", value: 1});
       
    var result: collection ArrayCollection = new ArrayCollection();
    var flag: Boolean;
    for (var i: int = 0; i)< source.length;="" i++)="">
    flag = false;
    for (var j int = 0; j< result.length;="" j++)="">
    If (result.getItemAt (j) ['name'] is {source.getItemAt (i) ["name"])}
    result.getItemAt (j) ['value'] is (result.getItemAt (j) ['value'] + source.getItemAt (i) ["value"]);.
    flag = true;
    break;
    }
    }
    If (! flag) {}
    result.addItem (source.getItemAt (i));
    }
    }
    for (var K:: int = 0; k)< result.length;="" k++)="">
    Alert.Show (result.getItemAt (k) ['name'] + '-' + (k) result.getItemAt ["value"]);
    }
    }

  • to access the data in the ArrayCollection collection


    accountingdata:ArrayCollection = new ArrayCollection (ArrayUtil.toArray (event.result));

    where event.result is a VO comes from a remote call

    The original Version contains a declaration of the variables:
    var date
    amount of the var
    etc...


    In my opinion, I use accountingdata as a DataProvider for my DataGrid, at the same time I need to access the VO.date of accountingdata of type ArrayCollection collection.
    Can someone tell me please how to do this?

    Thank you

    accountingdata.getItemAt (n) .date;

    Tracy

  • How to check whether or not the arraycollection collection is initialized

    Hi all

    I am bit new to use the collection arraycollection in flex. I'm having this particular scenario, where I get Server data in a table. So I have to check if the arracollection I created is initialized or not. If it is not initialized I need to initialize it or other wise, just add collection from table to table. Here is the code snippet

    currentTrajectory = new collection ArrayCollection (event.result as Array);

    var _multiTrajectoryEvent:MultiTrajectoriesEvent;

    _multiTrajectoryEvent = new MultiTrajectoriesEvent (MultiTrajectoriesEvent.DRAW_AUTO_TRAJ);

    If (!) (_multiTrajectoryEvent.trajectories.source is nothing))

    {

    _multiTrajectoryEvent.trajectories.addItem (currentTrajectory);

    }

    else

    {

    _multiTrajectoryEvent.trajectories = new ArrayCollection ([currentTrajectory]);

    }

    But unfortunately the above code does not work for me, because the arraycollection collection is not initialized first, there is no way of checking me if it is initialized later or not as the compiler gives me the error checking to null...

    Can any Walter suggest how can I check if the table collection is initialized or not?

    I would appreciate any suggestions and thouhgts for the same

    Thank you

    Akshay

    Sorry to say, but it's not the right approach...

    I'm abt don't know what is exactly done so I'll give a generic example...

    I have an ArrayCollection collection...

    private var arrC:ArrayCollection;

    Maybe it's getting used internally in several places, so you be sure if she be initialized already or not. Then use a code something like that...

    If (arrC! = null & arrC.length > 0)

    {

    ...

    ...

    }

    If you are using

    If (arrC.Length > 0)

    {

    ...

    ...

    }

    and it is not initialised it will give exceptional at the time to compile...

    For a logic if(a && b) be true both a and b must be true, so if same first one (a) is false it will not evaluate the second logic (b).

    Thus, the previous logic works.

    concerning

    Nishant

  • get the fields of the arraycollection collection?

    I want to loop through a collection of table and access all the items (columns)

    the arrayCollection collection looks so

    .columnOne [1]
    .columnTwo [1]
    .columnThree [1]
    .columnfour [1]

    [Bindable] public var dataSet:ArrayCollection = new ArrayCollection();

    protected function application1_creationCompleteHandler(event:FlexEvent):void

    {

    TODO self-generating method stub

    var d: Array = new Array()

    var int count = 5;

    var c:Number, r: Number;

    for (var i: int = 0; i<>

    {

    c = Math.Floor (Math.Random () * 10)

    r = Math.Floor (Math.Random () * 10)

    d.push ({cost: i + 1})

    Recipes: 2 * i + 1

    });

    }

    dataSet.source = d;

    Call();

    }

    function call (): void

    {

    for each (var point: Object in dataSet)

    {

    (var key: string in point)

    {

    trace (Key)

    trace ([Key] Item)

    }

    }

    }

  • How to add a new column to an existing item to an arraycollection collection?

    Hello

    I have a collection of arraycollection, acLeaseContract, which has this structure:

    Capture.JPG

    These are the columns and their respective data I get from main system. Now, I would like to add 2 more columns, after TenantName.

    I can iterate through this collection arraycollection, creating an object, add all columns again to the new object, and also add new columns that I want to add and then add that object to the arraycollection collection.

    for (i = 0; i < acLeaseContract.length; i ++) {}

    var o: Object = new Object();

    o.ContNo = acLeaseContract [i]. ContNo;

    o.ContType = acLeaseContract [i]. ContType;

    o.EndDt = acLeaseContract [i]. EndDt;

    .

    .

    .

    .

    o.TenantName = acLeaseContract [i]. TenantName;

    o.MyNewColumn1 = "somevalue";

    o.MyNewColumn2 = "somevalue";

    acLeaseContract.addItemAt (o, i);

    }

    But I think it's very painful and long, because we re building the collection whole arraycollection once again, just to add a couple of more columns.

    Is there a clever way to update the collection arraycollection with new entries, if yes can you pls tell me how can this be achieved?

    Thanks for your help...

    -Deepak

    Hello Deepak,

    Try to use the ObjectUtil.copy method. This will create a complete copy of your object as:

    var tempArray:Array = ObjectUtil.copy (acLeaseContract.source) in the table;

    acLeaseContract = new ArrayCollection (tempArray);

    You will avoid your iteration for simply copy your arrayCollection collection deeply.

    Now, when you look at acLeaseContract it will all contain the dataStructure as an object. Now, you are free to add any number of column to any node.

    Hope this helps you.

    See you soon

    -Vikash

Maybe you are looking for