Solved

How can I get and set contents of a particular cell in Flex DataGrid? e.g. myDG.Cells(col,row) should return me contents of Cell at [col] Column

Posted on 2009-05-13
3
399 Views
Last Modified: 2012-08-13
How can I get and set contents of a particular cell in Flex DataGrid? e.g. myDG.Cells(col,row) should return me contents of Cell at [col] Column.
I have some function
private function updateCells():void {
....
.....
}
In my Flex DataGrid I have 7 columns out of which 4 has been binded with dataFields but rest of the 3 need some calculation done on the basis of those 4 columns.
I call updateCells function on creationComplete event of the myDG (My DataGrid).

Any help would be appreciated. Thanks a ton in advance.
0
Comment
Question by:Aloha_Technology
3 Comments
 
LVL 5

Accepted Solution

by:
Fuzzy_Logic_ earned 50 total points
ID: 24381545
You need to look at this differently, the DataGrid just displays data from a list/array. Setting one cells value is done by setting the value in the object
the DataGrid is bound to.

Below is how I would handle a simple Cost Quantity TotalPrice grid. Hopefully it might provide you with some help.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">

   

   <mx:Script>

       <![CDATA[

           import ee.Order;    // importing your custom class

           import mx.collections.ArrayCollection;

           

           // build example class Order collection

           [Bindable] // make sure its bindable

           public var egAC:ArrayCollection = new ArrayCollection;

           

           public function init():void // this is just to make up some data

           {
 

               var x:int;

               for ( x = 0; x < 4; x++ )

               {

                   var newOrder:Order = new Order(); // initialize new Object of type Order

                   

                   newOrder.Quantity = 0;

                   newOrder.Cost = ( x + 2 ) * 2 / 2;   // making up costs
 

                   egAC.addItem( newOrder ); // add order to array collection

               }

               

           }

           

       ]]>

   </mx:Script>

   

   <mx:DataGrid dataProvider="{egAC}" editable="true">

        <mx:columns>

            <mx:DataGridColumn dataField="Cost"  editable="false"/>

            

            <mx:DataGridColumn dataField="Quantity"/> 

            <mx:DataGridColumn dataField="TotalPrice"  editable="false"/>

        </mx:columns>

       

   </mx:DataGrid> 

</mx:Application>
 

// this class is in src/ee folder
 

package ee

{

    public class Order

    {
 

        public var Cost:Number;

        public var Quantity:Number;
 

        public function get TotalPrice():Number        // getter function

        {

            return Cost * Quantity; 

        }
 

    }

}

Open in new window

0
 
LVL 29

Expert Comment

by:dgofman
ID: 37499045
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Air application in online mode and offline mode 4 416
google maps with flash 1 371
labelFunction 3 274
displaying tif image on flex side 1 304
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now