You should have seen a pattern where the data setter stores the data
object in a backing variable like _data and calls invalidateProperties.
 
In commitProperties(), you should see code that pulls fields out of the
data object and stuffs them into UI widgets much like you did in the
rest of your data setter.
 
However, the .data item is going to be an entry in the collection.
You've built a collection of objects that nust contain name and an empty
string for assesment.  If it contained the original XML for that
student, then you could access it from with in the renderer.
 
columnCollection.addItem({Name:xmlCurrGrades..student[i].name,Assesment:
"", rawData: xmlCurrGrades..student[i] }

You would set dataField to "rawData", but since you are getting a
complex object, I would just ignore it and rewrite the mapping code more
like:
 
override protected function commitProperties():void
{
 if([EMAIL PROTECTED] == 0! )
                {
                    docBtn.setStyle("color","yellow");
                }
                else
                {
                    docBtn.setStyle("color","orange");
                }
                
                if([EMAIL PROTECTED] == 0)
                {
                    feedBkBtn.setStyle("color","green");
                }
                else
                {
                    feedBkBtn.setStyle("color","blue");
                }
                
                txarea.text = [EMAIL PROTECTED] ;

}


________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Wayne LaRochelle
Sent: Friday, September 28, 2007 11:12 AM
To: [email protected]
Subject: Re: [flexcoders] DataGrid cell access question



HI!!

I have taken a look at many of the itemRenderer examples, but I have not
seen what I am trying to do.

I am building a grading screen. the screen is a DataGrid with an unknown
number of rows and columns so I am building it dynamically.

for this test its just 1 row of 2 columns

=======================================================================
for(var i:Number = 0; i < numOfStudents; i++)
{
            //add data to the ArrayCollection
 
columnCollection.addItem({Name:xmlCurrGrades..student[i].name,Assesment:
"" }
}    
      
        // make the ArrayCollection the Dataprovider
        gradeGrid.dataProvider = columnCollection;
        gradeGrid.x = 350;
        gradeGrid.y = 100;
        
        for (var i:Number = 1; i<gradeGrid.columns.length; i++)
        {
            // grab the column instances
            var gradeGridCol:DataGridColumn = gradeGrid.columns[i];
         
            // assign the new item renderer
            var renderer:ClassFactory = new
ClassFactory(twoBtnPlusTextArea);

            // assign our custom renderer
             gradeGridCol.itemRenderer = renderer;
                     
        }
        // add the dataGrid to the screen

        addChild(gradeGrid);
========================================================================

Each DataGrid Cell contain 2 buttons and a Text field. the data from the
XML looks like this for each cell

 [EMAIL PROTECTED]);
 [EMAIL PROTECTED]);
[EMAIL PROTECTED]);

What I don't understand is how to get this data into the data property.
The "dataField" is only a single String.

My override of set data() in the itemRenderer looks like this

========================================================================
=
override public function set data(value:Object):void
        {
            if(value != null)
            {
                super.data = value;

                if(value.docStatus == 0! )
                {
                    docBtn.setStyle("color","yellow");
                }
                else
                {
                    docBtn.setStyle("color","orange");
                }
                
                if(value.feedBKStatus == 0)
                {
                    feedBkBtn.setStyle("color","green");
                }
                else
                {
                    feedBkBtn.setStyle("color","blue");
                }
                
                txarea.text = value.gradeData;
            }
        }
======================================================

Thanks













----- Original Message ----
From: Alex Harui <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, September 27, 2007 4:40:01 PM
Subject: RE: [flexcoders] DataGrid cell access question



Every example out there should be doing this.  Look at the source for
mx.controls. listClasses. TileListItemRend erer.  You can also find
examples on my blog (blogs.adobe. com/aharui)

________________________________

From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups. com]
On Behalf Of Wayne LaRochelle
Sent: Thursday, September 27, 2007 3:05 PM
To: [EMAIL PROTECTED] ups.com
Subject: Re: [flexcoders] DataGrid cell access question



HI!!

thanks for responding.

I'm confused about the use of the data property can you aim me in a
direction of an example???

Thanks







----- Original Message ----
From: Alex Harui <[EMAIL PROTECTED] com>
To: [EMAIL PROTECTED] ups.com
Sent: Thursday, September 27, 2007 12:55:12 PM
Subject: RE: [flexcoders] DataGrid cell access question



renderers are data driven.  The .data property should hold the items
from the XML file and you should set the buttons and textArea based on
what you find in the .data property.

________________________________

From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups. com]
On Behalf Of waynelll
Sent: Thursday, September 27, 2007 11:42 AM
To: [EMAIL PROTECTED] ups.com
Subject: [flexcoders] DataGrid cell access question



HI!!

I have a question about using a DataGrid with a custom itemRender. 

Each of my DataGrid Cells contains an HBox within which are 2 buttons
and a text field. I realize that there are performance issues with
this design but these are my current specs.

The problem I am having is how to initialize the two buttons and the
text area at startup. Each button can be in one of four states and the
text area can contain any number between 1 and 100, the info comes out
of a XML file which I read in at startup.

I have been unsuccessful in trying to walk through the DataGrid using 
getChildAt to gain access to the Cell and Buttons.

I'm looking for any ideas. 

WAYNELLL





________________________________

Yahoo! oneSearch: Finally, mobile search that gives answers
<http://us.rd.yahoo.com/evt=48252/*http://mobile.yahoo.com/mobileweb/one
search?refer=1ONXIC> , not web links. 



________________________________

Tonight's top picks. What will you watch tonight? Preview the hottest
shows
<http://us.rd.yahoo.com/tv/mail/tagline/tonightspicks/evt=48220/*http://
tv.yahoo.com/>  on Yahoo! TV. 

 

Reply via email to