ArrayCollection to populate Datagrid

Hi,
Im having problems getting my own array data to bind to a
dataGrid. I've tried formating my array data several ways but none
work. Here is an example of one of the iterations i have tried
which i beleive should work. I build my array like this ...
for(i) {
arrayName.push( [{ fieldName1: value
, fieldName2: value}] );
which gives me a nice 2d array. this is put in an
arrayCollection which is bindable....
arrayCol = new ArrayCollection( arrayName);
and it is set as the dataProvider for my grid and the
fieldNames are set as the column dataFields ...
<mx:DataGrid x="424" y="425" height="125" width="340"
id="grd" editable="true" enabled="true"
dataProvider="{arrayCol}">
<mx:columns>
<mx:DataGridColumn headerText="Tag"
dataField="fieldName1" editable="false"/>
<mx:DataGridColumn headerText="Tag Value"
dataField="fieldName1" editable="true"/>
</mx:columns>
</mx:DataGrid>
The dataGrid does populate in the sense that i am allowed to
select the rows; the number of rows that my array consists of ...
however the cells are empty. I've spent a fair time trying to work
this out and search the docs / this forum. If anyone has any
recommendations about how to bind array / arrayCollection data to a
dataGrid it would be greatly appreciated.
Regards

The way you have it structured, it looks like you have a
two-dimensional array
where the second dimension always just contains a single
item. Unless I'm
misinterpreting your goal, the way to change this would be to
remove the extra
left/right brackets in your arrayName.push:
change
arrayName.push( [{ fieldName1: value<i> , fieldName2:
value<i>}] );
to
arrayName.push( { fieldName1: value<i> , fieldName2:
value<i>} );
That way, you have a one-dimensional array, but each item in
that array has a
field named 'fieldName1' and another field named
'fieldName2'.
Here is a complete sample that works for me (with the latest
internal build --
I haven't tried beta 3):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="initData()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
public var mydata:Array;
[Bindable]
public var arrayCol:ArrayCollection;
private function initData():void
mydata = [];
mydata.push( { fieldName1: '1', fieldName2: '2' } );
mydata.push( { fieldName1: '3', fieldName2: '4' } );
arrayCol = new ArrayCollection(mydata);
]]>
</mx:Script>
<mx
ataGrid x="424" y="425" height="125" width="340"
id="grd" editable="true"
enabled="true" dataProvider="{arrayCol}">
<mx:columns>
<mx
ataGridColumn headerText="Tag" dataField="fieldName1"
editable="false"/>
<mx
ataGridColumn headerText="Tag Value"
dataField="fieldName2"
editable="true"/>
</mx:columns>
</mx
ataGrid>
</mx:Application>
Mike Morearty
Developer, Flex Builder team
http://www.morearty.com/blog
McDusty wrote:
> Hi,
>
> Im having problems getting my own array data to bind to
a dataGrid. I've tried
> formating my array data several ways but none work. Here
is an example of one
> of the iterations i have tried which i beleive should
work. I build my array
> like this ...
>
> for(i) {
> arrayName.push( [{ fieldName1: value<i> ,
fieldName2: value<i>}] );
> }
>
> which gives me a nice 2d array. this is put in an
arrayCollection which is
> bindable....
>
> arrayCol = new ArrayCollection( arrayName);
>
> and it is set as the dataProvider for my grid and the
fieldNames are set as
> the column dataFields ...
>
> <mx
ataGrid x="424" y="425" height="125" width="340"
id="grd" editable="true"
> enabled="true" dataProvider="{arrayCol}">
> <mx:columns>
> <mx
ataGridColumn headerText="Tag" dataField="fieldName1"
> editable="false"/>
> <mx
ataGridColumn headerText="Tag Value"
dataField="fieldName1"
> editable="true"/>
> </mx:columns>
> </mx
ataGrid>
>
> I've spent a fair time trying to work this out and
search the docs / this
> forum. If anyone has any recommendations about how to
bind array /
> arrayCollection data to a dataGrid it would be greatly
appreciated.
>
> Regards
>

Similar Messages

  • Edit filtered ArrayCollection messes up Datagrid

    I understand Datagrid + itemrenderer is a frustrating issue
    sometimes. After Googling around, I got no luck solving my problem.
    It goes like this:
    I have an ArrayCollection
    objectArray as the dataprovider for a datagrid. I applied a
    filtered function on
    objectArray and the datagrid displayed the filtered array
    with no problem. However, when I looped through the filtered array
    and made some changes, the datagrid went crazy. The order got
    changed and some of the changed values didn't show up as changed.
    Did anyone come across the same issue? Can anyone give me
    some idea of what's going on?
    Thanks.

    mmm...
    Filter should be working, lets try to change Item for object.
    private function changeValue():void {
    for each (var item:Object in myArray) {
    item.value = true;
    myArray.refresh();
    "scabbage" <[email protected]> wrote in
    message
    news:[email protected]...
    > Ok, I think I found where the problem is. My code looks
    like this:
    >
    >
    >
    > ----------
    > <mx:Script>
    > <![CDATA[
    >
    > private function applyFilter():void {
    > myArray.filterFunction = myFilter;
    > myArray.refresh();
    > }
    >
    > private function changeValue():void {
    > for each (var item:Item in myArray) {
    > item.value = true;
    > }
    > myArray.refresh();
    > }
    >
    >
    > // simple filter
    > private function myFilter(item:Object):void {
    > if (item.id > 5 && item.id < 20)
    > return true;
    > else
    > return false;
    > }
    >
    > ]]>
    > </mx:Script>
    >
    > <mx:DataGrid dataProvider="{myArray}"/>
    > <mx:Button label="filter" click="applyFilter()"/>
    > <mx:Button label="change value"
    click="changeValue()"/>
    >
    >
    >
    > -------------------------
    >
    > So what causes the problem is the "changeValue"
    function. Solution to my
    > problem: bring "myArray.refresh()" inside the loop. So
    instead of doing a
    > refresh after all the values are changed, refresh the
    array EVERY TIME you
    > change a value. I realized that without doing this, the
    "for each" loop
    > doesn't
    > loop through the filtered array correctly. Some items
    gets accessed twice
    > and
    > some don't get accessed at all. This explains the "true,
    false, true,
    > false,
    > ..." alternating result I got previously.
    >
    > However, I was not able to reproduce this problem using
    a 5000-item toy
    > ArrayCollection (different objects). Flex made the right
    value changes
    > with
    > only one array refresh at the end.
    >
    >
    >
    quote:
    Originally posted by:
    Newsgroup User
    > Sorry.. I can't help you without see some code.
    > Rgds
    >
    > JFB
    >
    >
    > "scabbage" <[email protected]> wrote in
    message
    > news:[email protected]...
    > > JFB,
    > >
    > > I followed what you said and did a
    myArray.refresh() after I changed all
    > > my
    > > myArray.someProperty from false to true (myArray is
    the filtered array).
    > > However, in the Datagrid, the someProperty column
    didn't show "true"
    > > everywhere, but with true and false alternating
    (false, true, false,
    > > true,
    > > false...) across the datagrid. Any idea how this
    coud be solved?
    > >
    > > Thanks.
    > >
    >
    >
    >
    >
    >
    >

  • Populate datagrid and draw linechart based on xmlList

    I am generating dynamic xml structure like this
    <root>
      <OPVector>
        <Distance>0</Distance>
        <Height1>100</Height1>
        <Height2>200</Height2>
        <Height3>300</Height3>
      </OPVector>
      <OPVector>
        <Distance>100</Distance>
        <Height1>200</Height1>
        <Height2>300</Height2>
        <Height3>400</Height3>
      </OPVector>
      <OPVector>
        <Distance>200</Distance>
        <Height1>300</Height1>
        <Height2>400</Height2>
        <Height3>500</Height3>
      </OPVector>
    </root>
    What i have to do is to populate data grid based on this xml structure and draw a line chart where distance is category axis (x-axis) and Height1, Height2 etc are line series . No of Height fields depends on how many height values are entered by user (in text field Height1, Height2, Height3, Height4, Height5,Height6).
    Given is the code of my application ....
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="905" height="482" creationComplete="init();">
    <mx:Script>
    <![CDATA[
    import mx.events.IndexChangedEvent;
    private var dataProvider:XMLList = new XMLList();
    private var initDist:int ;
    private var offset:int  ;
    private var finalDist:int;
    private var height1:int;
    private var height2:int;
    private var height3:int;
    private var height4:int;
    private var height5:int;
    private var height6:int;
    private var heat:int;
    private var dataOP:XMLList;
    public function init():void{
    initDist = parseInt(txtInitDist.text);
    offset = parseInt(txtOffset.text);
    finalDist = parseInt(txtFinalDist.text);
    height2 = parseInt(txtHeight1.text);
    height2 = parseInt(txtHeight2.text);
    height3 = parseInt(txtHeight3.text);
    height4 = parseInt(txtHeight4.text);
    height5 = parseInt(txtHeight5.text);
    height6 = parseInt(txtHeight6.text);
    heat = parseInt(txtHeat.text);
    public function getOP():void{
    dataOP = createXMLObject();
    currentState='stateOP';
    trace(dataOP.toXMLString());
    } // public function getOP():void{
    public function createXMLObject():XMLList{
    var data:XMLList = XMLList(<root></root>);
    for (var i:int=initDist;i<=finalDist;i+=offset){
    var x:XMLList = new XMLList(<OPVector></OPVector>);
    var distance:String = "<Distance>"+i+"</Distance>";
    var strHeight1:String = "<Height1>"+(parseInt(txtHeight1.text)+i)+"</Height1>";
    var strHeight2:String = "<Height2>"+(parseInt(txtHeight2.text)+i)+"</Height2>";
    var strHeight3:String = "<Height3>"+(parseInt(txtHeight3.text)+i)+"</Height3>";
    var strHeight4:String = "<Height4>"+(parseInt(txtHeight4.text)+i)+"</Height4>";
    var strHeight5:String = "<Height5>"+(parseInt(txtHeight5.text)+i)+"</Height5>";
    var strHeight6:String = "<Height6>"+(parseInt(txtHeight6.text)+i)+"</Height6>";
    x.appendChild(distance);
    if (txtHeight1.text != ""){
    x.appendChild(strHeight1);
    if (txtHeight2.text != ""){
    x.appendChild(strHeight2);
    if (txtHeight3.text != ""){
    x.appendChild(strHeight3);
    if (txtHeight4.text != ""){
    x.appendChild(strHeight4);
    if (txtHeight5.text != ""){
    x.appendChild(strHeight5);
    if (txtHeight6.text != ""){
    x.appendChild(strHeight6);
    data.appendChild(x);
    } // for (var i:int=initDist;i<finalDist;i+=offset){
    return data;
    } // public function createXMLObject():void
    ]]>
    </mx:Script>
    <!-- States Definition -->
    <mx:states>
    <mx:State name="stateOP">
    <mx:RemoveChild target="{btnOP}"/>
    <mx:RemoveChild target="{btnThermal}"/>
    <mx:RemoveChild target="{txtHeight5}"/>
    <mx:RemoveChild target="{txtHeight6}"/>
    <mx:RemoveChild target="{txtFinalDist}"/>
    <mx:RemoveChild target="{label1}"/>
    <mx:RemoveChild target="{label2}"/>
    <mx:RemoveChild target="{label3}"/>
    <mx:RemoveChild target="{txtHeight3}"/>
    <mx:RemoveChild target="{txtHeight4}"/>
    <mx:RemoveChild target="{txtOffset}"/>
    <mx:RemoveChild target="{label4}"/>
    <mx:RemoveChild target="{label5}"/>
    <mx:RemoveChild target="{label6}"/>
    <mx:RemoveChild target="{txtHeight1}"/>
    <mx:RemoveChild target="{txtHeight2}"/>
    <mx:RemoveChild target="{txtInitDist}"/>
    <mx:RemoveChild target="{label7}"/>
    <mx:RemoveChild target="{label8}"/>
    <mx:RemoveChild target="{label9}"/>
    <mx:RemoveChild target="{txtHeat}"/>
    <mx:RemoveChild target="{label13}"/>
    <mx:AddChild position="lastChild">
    <mx:DataGrid x="57" y="112" width="274" height="336" id="dgPressure" dataProvider="{dataOP}">
    <mx:columns>
    <mx:DataGridColumn headerText="Column 1" dataField="col1"/>
    <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
    <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:AddChild>
    <mx:AddChild position="lastChild">
    <mx:LineChart x="382" y="112" id="lcOverPressure" width="513" height="182">
    <mx:series>
    <mx:LineSeries displayName="Series 1" yField=""/>
    </mx:series>
    </mx:LineChart>
    </mx:AddChild>
    <mx:AddChild position="lastChild">
    <mx:Legend dataProvider="{lcOverPressure}" x="810" y="51"/>
    </mx:AddChild>
    <mx:AddChild position="lastChild">
    <mx:Button x="382" y="426" label="Close" id="btnClose" click="currentState=''"/>
    </mx:AddChild>
    </mx:State>
    <mx:State name="stateTR">
    <mx:RemoveChild target="{txtHeat}"/>
    <mx:RemoveChild target="{txtHeight1}"/>
    <mx:RemoveChild target="{txtHeight3}"/>
    <mx:RemoveChild target="{txtHeight5}"/>
    <mx:RemoveChild target="{txtHeight2}"/>
    <mx:RemoveChild target="{txtHeight4}"/>
    <mx:RemoveChild target="{txtHeight6}"/>
    <mx:RemoveChild target="{txtInitDist}"/>
    <mx:RemoveChild target="{txtOffset}"/>
    <mx:RemoveChild target="{txtFinalDist}"/>
    <mx:RemoveChild target="{label13}"/>
    <mx:RemoveChild target="{label7}"/>
    <mx:RemoveChild target="{label4}"/>
    <mx:RemoveChild target="{label3}"/>
    <mx:RemoveChild target="{label8}"/>
    <mx:RemoveChild target="{label5}"/>
    <mx:RemoveChild target="{label1}"/>
    <mx:RemoveChild target="{label9}"/>
    <mx:RemoveChild target="{label6}"/>
    <mx:RemoveChild target="{label2}"/>
    <mx:RemoveChild target="{btnOP}"/>
    <mx:RemoveChild target="{btnThermal}"/>
    <mx:AddChild position="lastChild">
    <mx:DataGrid x="39" y="108" width="301" height="364">
    <mx:columns>
    <mx:DataGridColumn headerText="Column 1" dataField="col1"/>
    <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
    <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:AddChild>
    <mx:AddChild position="lastChild">
    <mx:LineChart x="420" y="108" id="linechart1" width="475" height="181">
    <mx:series>
    <mx:LineSeries displayName="Series 1" yField=""/>
    </mx:series>
    </mx:LineChart>
    </mx:AddChild>
    <mx:AddChild position="lastChild">
    <mx:Legend dataProvider="{linechart1}" x="810" y="13"/>
    </mx:AddChild>
    </mx:State>
    </mx:states>
    <!-- States Definition -->
    <!-- Controls Definition -->
    <mx:TextInput x="331" y="95" width="62" id="txtHeat" text="8"/>
    <mx:TextInput x="231" y="229" width="62" id="txtHeight1" text="100"/>
    <mx:TextInput x="231" y="259" width="62" id="txtHeight3" text="300"/>
    <mx:TextInput x="231" y="289" width="62" id="txtHeight5"/>
    <mx:TextInput x="357" y="229" width="62" id="txtHeight2" text="200"/>
    <mx:TextInput x="357" y="259" width="62" id="txtHeight4"/>
    <mx:TextInput x="357" y="289" width="62" id="txtHeight6"/>
    <mx:TextInput x="580" y="229" width="62" id="txtInitDist" text="0"/>
    <mx:TextInput x="580" y="259" width="62" id="txtOffset" text="100"/>
    <mx:TextInput x="580" y="289" width="62" id="txtFinalDist" text="2000"/>
    <mx:Label x="298" y="97" text="Heat" id="label13"/>
    <mx:Label x="168" y="231" text="Height1" id="label7"/>
    <mx:Label x="168" y="261" text="Height3" id="label4"/>
    <mx:Label x="168" y="291" text="Height5" id="label3"/>
    <mx:Label x="302.5" y="231" text="Height2" id="label8"/>
    <mx:Label x="301" y="261" text="Height4" id="label5"/>
    <mx:Label x="301" y="291" text="Height6" id="label1"/>
    <mx:Label x="484" y="231" text="Initial Distance" id="label9"/>
    <mx:Label x="533" y="261" text="Offset" id="label6"/>
    <mx:Label x="490" y="291" text="Final Distance" id="label2"/>
    <mx:Button x="298.5" y="384" label="Pressure Effects" id="btnOP" click="getOP()"/>
    <mx:Button x="464.5" y="384" label="Thermal Effects" width="142" id="btnThermal"/>
    <mx:Label x="298" y="10" text="Weather Effects" fontWeight="bold" fontSize="18"/>
    <!-- Controls Definition -->
    </mx:Application>

    I suggest that you first not try to cram all of your code into the MXML. Though many examples use this approach for quick copy-and-pasting, it is bad style and not as maintainable. You should use the code-behind approach where your MXML is strictly for layout of the view and its root element is a custom class that extendeds the usual base (in this case Application).
    Since the number of series in your line cart may vary, what you will need to do is dynamically create them whenever the data provider is updated.

  • Populate datagrid problem

    Hi there
    I am having problems populating my datagrid with xml data
    returned from an instance of a class.
    Here is the xml data that is returned from the instance
    <summaryScreen>
    <exam>
    <type>GCE</type>
    <qualification>Extended Project
    Qualification</qualification>
    <code>1991</code>
    <students>12</students>
    <marked>4</marked>
    <submitted>8</submitted>
    <series>november</series>
    </exam>
    <exam>
    <type>GCE</type>
    <code>1991</code>
    <qualification>Extended Project Qualification -
    TH</qualification>
    <students>14</students>
    <marked>3</marked>
    <submitted>4</submitted>
    <series>september</series>
    </exam>
    <exam/>
    </summaryScreen>
    And here is my code for the datagrid
    <mx:DataGrid
    dataProvider="{_summaryScreenData.getXMLData()}">
    <mx:columns>
    <mx:DataGridColumn headerText="Type" dataField="type"
    width="60" />
    <mx:DataGridColumn headerText="Qualification"
    dataField="qualification" width="140"/>
    <mx:DataGridColumn headerText="Code" dataField="code"
    width="140" />
    <mx:DataGridColumn headerText="Students"
    dataField="students" width="70" />
    <mx:DataGridColumn headerText="Marked" dataField="marked"
    width="70" />
    <mx:DataGridColumn headerText="Submitted"
    dataField="submitted" width="90"/>
    <mx:DataGridColumn headerText="Series" dataField="series"
    width="70"/>
    <mx:DataGridColumn headerText="Days Left"
    dataField="daysLeft"/>
    </mx:columns>
    </mx:DataGrid>
    Can anyone point me in the right direction to get this data
    into the datagrid?
    Thanks!

    Hi,
    please look at your XML there is a extra and wrong
    "<exam/>" closing tag.
    still you have a problem. Plz look at the code which I tried
    it worked fine.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Model id="xyz">
    <summaryScreen>
    <exam>
    <type>GCE</type>
    <qualification>Extended Project
    Qualification</qualification>
    <code>1991</code>
    <students>12</students>
    <marked>4</marked>
    <submitted>8</submitted>
    <series>november</series>
    </exam>
    <exam>
    <type>GCE</type>
    <code>1991</code>
    <qualification>Extended Project Qualification -
    TH</qualification>
    <students>14</students>
    <marked>3</marked>
    <submitted>4</submitted>
    <series>september</series>
    </exam>
    </summaryScreen>
    </mx:Model>
    <mx:Script>
    <![CDATA[
    import mx.utils.ArrayUtil;
    ]]>
    </mx:Script>
    <mx:DataGrid
    dataProvider="{mx.utils.ArrayUtil.toArray(xyz.exam)}">
    <mx:columns>
    <mx:DataGridColumn headerText="Type" dataField="type"
    width="60" />
    <mx:DataGridColumn headerText="Qualification"
    dataField="qualification" width="140"/>
    <mx:DataGridColumn headerText="Code" dataField="code"
    width="140" />
    <mx:DataGridColumn headerText="Students"
    dataField="students" width="70" />
    <mx:DataGridColumn headerText="Marked" dataField="marked"
    width="70" />
    <mx:DataGridColumn headerText="Submitted"
    dataField="submitted" width="90"/>
    <mx:DataGridColumn headerText="Series" dataField="series"
    width="70"/>
    <mx:DataGridColumn headerText="Days Left"
    dataField="daysLeft"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Application>

  • Populate Datagrid from database

    Using Adobe Flex Builder 3 Beta 2, I have successfully used
    the Data Source Explorer window to connect to the Northwind and
    Pubs database on my SQL 2005 server. I can see the schemas and
    tables, etc. I understand that currently I cannot simply drag and
    drop the fields into the datagrid (which would be nice) so how do I
    'wire up' a table to the data grid? Is there an example which you
    can refer me to (with source) that would explain that? I've
    successfully wired up a webservice, but not to a database listed in
    the Data Source Explorer. If there were an example that showed a
    CRUD data grid, that would help.

    Just to give you an update as to where I am and where I'm
    hung up, I was able to make a little bit of progress but not too
    far.
    1. I created a Flex Project (Web application) and specify
    Applcation Server Type: ASP.net.
    2. Next, I have the choice of specifying 'Use ASP .NET
    Development Server' or 'Use Internet Information Services (IIS). At
    the 'Usa ASP .NET Development Server', the error message at the top
    of this wizard window says (X) You don't have ASP .NET Development
    Server Installed. [Well, it may not be running but I do have it
    installed as part of the .NET 2.0 Framework.. it does exist]. So,
    because of the error, I have no choice but to use the alternate
    option, 'Use Internet Information Services (IIS).
    3. I specify my Web Application Root: d:\Flex3
    Projects\TestProj3 (I manually have to create the folder).
    4. I speciy my Web Application URL:
    http://localhost
    5. I click the Finish button.
    Note... I've already selected my Connectivity using the Data
    Source Explorer (which is available by selecting the following in
    Flex Builder: Windows, Otherviews, Connectivity, Data Source
    Explorer, and then adding in a database connection at my MS SQL
    2005 server, specifying username and password).
    6. Next, from Flex Builder, I select: Data, Create
    Application from Database, and specify the current project,
    connection (in my case, Northwind) and the employee table, etc. I
    click NEXT.
    7. I can select C# with web services or Visual Basic with Web
    Services, so I select Visual Basic.
    8. Select Finish.
    OK at this point, a lot of code (action script, webservices,
    etc. is auto-generated for me - kewl.. just like Dreamweaver :-)
    Now I'm ready to run the application.
    But wait - I know it won't run because I note that the ASP
    .NET Development Server is not running. However - I can start it
    from the windows command line.
    First thing I do is stop my local IIS server which is using
    Port 80.
    Next thing I do is open a windows command line and navigate
    to my .Net 2.0 Framework directory:
    cd \WINDOWS\Microsoft.NET\Framework\v2.0.50727
    and then I run the ASP .NET Web server at the same path that
    my application (above) is written to (again, typed in the command
    line window).
    start /b webdev.webserver /port:80 /path:"D:\Flex3
    Projects\TestProj3\bin"
    Finally, from the Flex Builder window, I right-click on the
    auto-build Employee.mxml table and select 'Run application'.
    After a few moments an Internet Explorer window comes up. I
    believe it says:
    http://localhost/bin/Employees.html
    and I change it to read:
    http://localhost/Employees.html
    and it runs.. well it runs, but with 'An unexpected error
    occured and it has been logged.'
    So that's as far as I have gotten but it does write the code.
    So am I to assume that whether I do this by hand or use the
    'auto-generated code' that I will be using WebServices to read and
    write from the MS SQL 2005 database?
    I would much rather my Flex Application open a connection to
    the database directly and send SQL statements. I'm guessing that
    might not be possible without some driver? Perhaps thats were Adobe
    Live Cycle comes in?
    Any insight (frm anyone) would be helpful. Thank you.

  • Datagrid ArrayCollection Timeout issue

    Has anyone else encountered this? I'm trying to populate a datagrid with a large amount of data (approx. 1800+ records). Using a ColdFusion backend, the RemoteObject executes the CFC to generate the SELECT statement, which takes approx. 20 seconds to finish execution.
    After this, the ResultEvent is returned and bound to an ArrayCollection. However, I get a #1502 error because the script takes longer than 60 seconds to execute.
    Rather than extending the script timeout (if possible), is there any way to populate (bind) the arraycollection to the datagrid in segments?

    That is my best bet if the solution I am looking for isn't possible. Hopefully I will be able to pass the sort columns back to the query for sorting...
    Currently I'm using a pagableArrayCollection. The RO calls the CFC, which executes the query. In the result event, the event.result is bound to a "holding" ArrayCollection, then a pagablearraycollection is created from the "holding" source.
    private function getData_result(event:ResultEvent):void {
         acHold = event.result as ArrayCollection;
         acData = new PagableArrayCollection(acHold.source);
    The dataprovider is acData.
    What I want to do is bind in segments, breaking the script segment into chunks so that it will not timeout. Now I'm wondering, is it timing out on binding acHold, acData, or displaying the datagrid.
    As is, the app attempts to load all of the data at once, but only 100 records are "displayed" in the datagrid, even though all of the data is actually bound.

  • DataGrid with dynamic columns & renderers

    I'm developing using Flash Builder 4 & Flex SDK 4.1.
    I need to manage very dynamic DataGrid components and keep their definitions, which are all part of a complex item renderer of an Offers list.
    The objects structure is simplified as follows -
    Data: Model --> Offers ArrayCollection --> Offer VO --> DataGrid data ArrayCollection & DataGrid columns Array
    View: List --> Offer Item Renderer --> DataGrid
    1. Since the DataGrid's columns property accepts only an Array (not ArrayCollection), it seems like Data Binding for defining the columns is very problematic.
    I tried to bind it to the source property of an ArrayCollection that would keep my columns definitions, but it didn't really work (mainly header display bugs).
    What is the recommended way to keep the dynamic columns definition of a DataGrid?
    2. Each column can have a set of dynamic properties, so I created a "mutant" - Column VO that extends DataGridColumn and got a dynamic properties ArrayCollection on it.
    The columns got a custom header renderer that includes an icon when there are properties.
    The header renderers got 4 main states (NotSelectedWithProperties, SelectedWithProperties, NotSelectedWithoutProperties & SelectedWithoutProperties).
    However, the header renderer area seems a bit buggy when maintaning dynamic columns.
    Any thoughts on the subject?
    3. Anyway, I ended up recreating the DataGrid's columns Array very often (copying the columns definition on the offer's item renderer's dataChange event handler).
    Note that the dynamic properties can be edited when the column is selected and I copy their values from the view back to the model when entering the state NotSelectedWithProperties.
    This feels way too complicated and I really try to keep it simple, inspite of the required complexity.
    Does anyone have better ideas?
    4. In some cases the column's item renderer should also be modified into another DataGrid (grid-in-grid).
    I used the MXDataGridItemRenderer with a DataGrid and included an ArrayCollection for the "newValue" returned by the editor.
    (I use RendererIsEditor=true and on updateComplete populate that variable with the DataGrid's dataProvider contents)
    When needed, I loop though the data objects of the parent DataGrid and populate the related field with an ArrayCollection of key-value objects that are displayed on the internal DataGrid.
    After adding this feature I encounter very strange bugs -
    a. After editing the grid-in-grid values and changing the column's state (selecting & deselecting), I get the following exception:
    ArgumentError. Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/setChildIndex()
    at mx.core::UIComponent/setChildIndex().......6993....
    All I could find about this is that it might be related to some context error or something, but I'm really stuck on this one.
    b. Sometimes another column might copy value from one row to another, running over the previous value.
    I'm not sure exactly what sequence of actions causes this behavior, but it's related to that itemRenderer for sure.
    c. Switching places with a column that uses the grid item renderer (headerShift) causes a stak overflow of StyleManager that tried to get style from the DataGridItemRenderer. This one I just found out, but couldn't reproduce a second time... strange!
    I'm pretty sure this caused another problem that I don't remember at the moment.
    The bottom line is that there got to be a better way to implement this feature within this already-complicated environment.
    Maybe I'm doing something very wrong here...
    Please advice and thanks for reading all this.

    Update on item 4a -
    This was a major issue (the main reason for opening this thread really) and I managed to resolve it!
    As part of my application, I override the default DataGrid behavior for column selection (headerRelease event).
    Instead of sorting, I change the column's header looks and define it as Selected (for showing its dynamic properties and enable its deletion).
    At first I did this by setting styles, but the look didn't refresh unless I created a new instance of the header renderer.
    Later I changed thi behavior to work with states, but I left the new header renderer instance creation commands and those lines created all the mess!
    Conclusion -
    If you define a custom header renderer for your datagrid column and then a custom item renderer, don't create a new instance of your header renderer!
    It would still be nice to get some response for the other issues I raised.
    Thanks and have a nice week.

  • How to populate DataGird with data returned from php page?

    Hi, I'm new in Flex, I try to populate DataGrid with data from PHP, My code is
    <mx:HTTPService 
    id="personRequest" result="getPerson(event)" url=http://localhost/searchPerson.php useProxy="false" method="POST" showBusyCursor="true" resultFormat="e4x">
    </ mx:HTTPService>
    <mx:DataGrid 
    id="searchResult" dataProvider="{???what to paste here???}" y="30">
    </mx:DataGrid>
    private  
    function getPerson(evt:ResultEvent):void { var res:XMLList = evt.result..dane as XMLList;searchResults =
    new XMLListCollection(res); 
    output from PHP
    <person>
    <dane>
    <name>ABC</name>
    <street>XLXXLX</street>
    </dane>
    <dane>
    <name>DEF</name>
    <street>YAYAYAY</street>
    </dane>
    </person>
    If I set the dataProvider as "searchResults" it doesn't work. I probably have to set as dataprovider any ArrayCollection , but I don't know how to convert my XMLListCollection to it.
    Could anyone help me populate Datagrid with
    name | streer
    ABC, XLXXLX
    DEF, YAYAYAY
    Best Regards,
    Mariusz

    Thanks for your reply, but I'm afraid it doesn't work :-( Could you browse my code and check what I'm doing wrong???
    full mxml code:
    <?xml version="1.0" encoding="utf-8"?><mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="personRequest.send()">
    <mx:Script><![CDATA[
         import mx.rpc.events.ResultEvent; 
         [Bindable]
         public var searchResultsXML:XML;  
         private  function getPerson(evt:ResultEvent):void 
          {          searchResultsXML = (evt.result
    as XML);
              trace(searchResultsXML);     }
    ]]></mx:Script>  
    <mx:HTTPService 
    id="personRequest" result="getPerson(event)" url=http://localhost/searchPerson.php useProxy="false"
    method="POST" showBusyCursor="true" resultFormat="e4x"></mx:HTTPService>
    <mx:DataGrid  id="searchResult" dataProvider="{searchResultsXML.dane}"></mx:DataGrid>
     </mx:Application> 
    trace statement returns:
    <person>
    <dane>
    <id>1</id>
    <nazwisko>Topczewski</nazwisko>
    <imie>Mariusz</imie>
    <imie2/>
    <miejscowosc>Bia?ystok</miejscowosc>
    <ulica>Nowogródzka</ulica>
    <dom>7B</dom>
    <lokal>25</lokal>
    </dane>
    <dane>
    <id>1</id>
    <nazwisko>Topczewski</nazwisko>
    <imie>Mariusz</imie>
    <imie2/>
    <miejscowosc>Bia?ystok</miejscowosc>
    <ulica>Sybiraków</ulica>
    <dom>15</dom>
    <lokal>27</lokal>
    </dane>
    </person>

  • Actionscript 3.0 ArrayCollection issue!!

    Hi there, in my mobile application I'm using an ArrayCollection to populate a list with a custom itemRenderer which includes a RadioButton. Now, when I click on the list items I'd like that the RadioButton selected property to be set to true. When I click another item, the previous RadioButton selected property to be false and the current set to true. I did the first part, I was able to set the selected property to true when the item is clicked but couldn't change it back when another item in the list is selected. Here is my Code:
    public var profileArray:ArrayCollection = new ArrayCollection([
        {entries:"1", name:"Guest", isSelected:"false"},
        {entries:"2", name:"Name1", isSelected:"false"},
        {entries:"3", name:"Name2", isSelected:"false"}
    in order to enable the radioButton id used the fallowing code:
    var currentlySelectedItem:Object = ProfileList.selectedItem;
    currentlySelectedItem.isSelected = true;
    profileArray.itemUpdated(currentlySelectedItem)
    and then pass the profileArray isSelected (true or false) property to the radioButton "selected" property.
    I don't know how to reset the "isSelected" proeprty to false for all item in the profileArray array collection.
    Please Help!
    Thank you

    What you can do is save the currently selected item, so you can update it again when it changes.
    private var _currentlySelectedItem:Object;
    private function updateSelection(selectedItem:Object):void
         if( _currentlySelectedItem != null)
               _currentlySelectedItem.isSelected = false;
              profileArray.itemUpdated(_currentlySelectedItem);
      _currentlySelectedItem = selectedItem;
      _currentlySelectedItem.isSelected = true;
      profileArray.itemUpdated(_currentlySelectedItem);

  • A DataGrid with a Custom ItemRenderer

    Hi all,
    I have a DataGrid whose DataProvider is bound to a simple Array. I have a custom ItemRenderer that includes a button that can remove the item itself (I don't want two separate columns with a remove button in one of them). However, I don't understand the behaviour - clicking the button rearranges the data in the DataGrid and sometimes duplicate the entries! See the example attached. Any idea what's happening?
    Martin.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete();" xmlns:local="*">
        <mx:Script>
            <![CDATA[
                [Bindable]
                public var _data : Array;
                protected function onCreationComplete() : void {
                    _data = new Array();
                    _data.push(1, 2, 3, 4, 5);
            ]]>
        </mx:Script>
        <mx:VBox>
            <mx:DataGrid dataProvider="{_data}">
                <mx:columns>
                    <mx:DataGridColumn>
                        <mx:itemRenderer>
                            <mx:Component>
                                <mx:HBox implements="mx.controls.listClasses.IDropInListItemRenderer" creationComplete="dataLabel.text = String(data);">
                                    <mx:Script>
                                        <![CDATA[
                                            import mx.collections.ArrayCollection;
                                            import mx.controls.DataGrid;
                                            import mx.controls.listClasses.BaseListData;
                                            protected var _listData : BaseListData;
                                            public function get listData() : BaseListData {
                                                return _listData;
                                            public function set listData(d : BaseListData) : void {
                                                _listData = d;
                                            protected function onClick(e : Event) : void {
                                                var dp : ArrayCollection = (owner as DataGrid).dataProvider as ArrayCollection;
                                                dp.removeItemAt(listData.rowIndex);
                                        ]]>
                                    </mx:Script>
                                    <mx:Label id="dataLabel" width="100%" />
                                    <mx:Button click="onClick(event);"/>
                                </mx:HBox>
                            </mx:Component>
                        </mx:itemRenderer>
                    </mx:DataGridColumn>
                </mx:columns>
            </mx:DataGrid>
        </mx:VBox>
    </mx:Application>

    creationComplete is rarely used in renderers.  See the itemrenderer posts on my blog
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Update variable after datagrid edited

    I have 4 variables that are numbers being retrieved and assigned to an arraycollection for a datagrid
    private var myDataProvider:ArrayCollection= new ArrayCollection([{col1:'Approaching headlights', col2:myVar1},
    {col1:'Bright lights in my eyes', col2:myVar2},
    {col1:'Dogs Barking', col2:myVar3},
    {col1:'Fighting with friends', col2:myVar4}]);
    The datagrid (col2) gets sorted in descending order and then the user is able to change the values.  Somehow I need to have the corresponding variable updated if/when a user edits that particular cell.  If I'm on the line with Dogs Barking and edit the value from say," 3" to "5", then myVar3 needs to be updated to "5' as well.  The datagrid could be in any order depending on what values have been assigned to each and I can't find a way to get those variables updated.

    Then you may be interested in the property "rendererIsEditor" available to datagrid columns.  Here is an adobe link going into more depth
    along with an example.
    http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_3.html

  • Datagrid sorting issue

    I have two datagrids. After a form is submitted, datagrid 1
    is populated. Clicking on any of the rows will submit to another
    query and populate datagrid 2.
    If I have submitted my form and datagrid 1 is populated, and
    I sort the columns, it will sort and kick of the second query.
    Instead of sending to the HTTP service directly when clicking
    on datagrid 1 header or row, I have it going to a routine. If the
    user has not selected a row, and clicks a column, it will sort but
    not submit.
    However, that only gets me half the way there. If a user
    selected a row in datagrid 1, and then sorts, it will still submit
    to datagrid 2. Again, I don't see why if I'm clearly clicking on
    the column header to sort that it should submit also.
    Is there a way to make the column header independent of the
    rows?

    I would not have expected that.
    Pass "event" into the itemClick handler.
    Use it to determine what was clicked, and do not make your
    data service call if it is the header row. Not exactly how to
    determine that, you will need to look at the contents of that
    event. Maybe rowIndex = -1?
    Tracy

  • Skip row in datagrid

    Is it possible to skip a row in a datagrid that uses an
    ArrayCollection as dataprovider ?
    I want to check if an arraycollection item contains X and if
    so then don't draw it.
    I use the same arraycollection in multiple datagrids and its
    only one of them I don't want to draw the specific item.

    "geiryt" <[email protected]> wrote in
    message
    news:g7v61v$q8h$[email protected]..
    > Is it possible to skip a row in a datagrid that uses an
    ArrayCollection as
    > dataprovider ?
    > I want to check if an arraycollection item contains X
    and if so then don't
    > draw it.
    > I use the same arraycollection in multiple datagrids and
    its only one of
    > them
    > I don't want to draw the specific item.
    Use a different ArrayCollection and the same source but a
    different
    filterFunction

  • How to format date and currency datafield in a Datagrid

    Hy folks
    I am getting my data from a web service (against a SQL server)
    After that convert the data in an ArrayCollection and
    Finally I use the ArrayCollection in a Datagrid ussing somethig like :
    <mx:collumns >
    <mx:DataGridcolumn datafield="EnvoiceDate" />
    <mx:DataGridcolumn datafield="EnvoiceValue" />
    How can I format a date tipe datafield in a Datagrid.
    I need to display da date in an format like  DD/MM/YYYY   ex     12/10/2009.
    I also need to display da number like 1345.87   as  1.345,87
    thanks in advance

    Binoy,
    create fields that refer to DATS and TIMS data types
    Thanks
    Bala Duvvuri
    Edited by: Bala Duvvuri on Aug 5, 2010 10:28 PM

  • DataGrid jumps on data refresh

    Hi,
    I have a datagrid control bound to an arraycollection. I also
    have a timer which updates the arraycollection with new data and
    call its refresh method every few seconds
    The problem is that the datagrid scrolls to the item that is
    selected and it looks very jumpy. How can i prevent this from
    happening?

    Actually, I discovered that I don't have to use itemUpdated()
    method when binding an arraycollection to a datagrid (notification
    of data change is sent to the view automatically)...
    What i did instead was simply update the properties of the
    objects inside of my arraycollection through a loop.
    for(var i:int = 0; i < mainCollection.length; i++){
    var item:Object = mainCollection.getItemAt(i);
    for (var qs:String in anotherCollection
    item[qs] = anotherCollection[item.id][qs];
    mainCollection.itemUpdated(item);
    But, since you are ADDING or REMOVING items, I'm not sure how
    useful the code above will be in helping you figure it out. Since I
    use it to update the items.

Maybe you are looking for

  • Itunes 11 appears to download my CD but it does not show up in my music?

    I insert my own CD. itunes goes through the importing process on each track, but when it is done, the new tracks do not show up in Music or Recently added.  Where is it?  I do not have itunes Match.  Any ideas?  I import my own CD's like this all the

  • Acrobat 9 install

         tried installing acrobat 9 standard in my windows 7 laptop.   installed fine... would not let me accept cancel or deline the licencing agreement.  at that exact moment my lap top became useless for any kind of search no videos or images would sh

  • Mousing over some UI elements doesn't always display the correct pointer

    When I mouse over some elements in a UI, sometimes the mouse cursor isn't correct. For example, when typing this message, if I open up 'Launchpad' by using the gesture, my mouse cursor stays as the text cursor, not the mouse pointer arrow, as I would

  • Why does iphone 5 email my photos as png? i need jpg file.

    I'm trying to email photos, save to my PC then download to a photo website. This particular website only recognizes jpg as images. I've never had this problem before. Is there another way to change setting to email photos as jpg instead of png? thank

  • Unable to update SQL Developer 4.0 EA1 to EA2

    Hi All Could any one please help me in updating SQL Developer 4.0 EA1 to EA2 using a Local File installation... I have a proxy which is blocking me from updating my SQL Developer.. I would appreciate if any once could share any link which contains a