what happens is as the grid is rendering the data it calls that
labelFunction and passes those 2 params to that function. the item param is
really an object containing that rows data, at which point you can look at
any value (property really) in that object and then do something with it.
its more of a 'behind the scenes' type of operation that happens
automagically.

On 2/13/07, jryano001 <[EMAIL PROTECTED]> wrote:

  It does kind of make sense but I'm just wondering how the checkData
function knows to look at my ArrayCollection and how the item:object
refers specifically to the row.

As I said before I am very new to all of this and it is a very steep
learning curve at the moment.

--- In [email protected] <flexcoders%40yahoogroups.com>, "Clint
Tredway" <[EMAIL PROTECTED]>
wrote:
>
> the item param is row data, what is in that row of the array
collection and
> the column is that column in the grid.
>
> basically what happens in this particular labelFunction is that it
looks at
> a specific field in the array collection and determine its value,
then it
> sets a string to be returned and displayed in that column for that
row. You
> could return a number, boolean etc just by changing the return type
of the
> function.
>
> make sense?
>
> On 2/13/07, jryano001 <[EMAIL PROTECTED]> wrote:
> >
> > Brilliant thanks for all your help.
> >
> > Can you do one more thing and explain exactly what the line below
is
> > doing please?
> >
> > checkData(item:Object,column:Object):String
> >
> > Is it converting the parsed XML data in my ArrayCollection to a
> > String before searching the converted string for the number 2?
> >
> > Thanks once again.
> >
> > --- In [email protected] <flexcoders%40yahoogroups.com><flexcoders%
40yahoogroups.com>, "Clint
> > Tredway" <grumpee@>
> > wrote:
> > >
> > > oops, at the bottom of the function put return retString;
> > >
> > >
> > > On 2/12/07, jryano001 <jryan@> wrote:
> > > >
> > > > Thanks for the response. This is more than likely me being
daft
> > but
> > > > I've used the code you provided and set the labelFunction of
> > > > checkData on the status DataGridColumn and I get an error in
Flex
> > > > stating:
> > > >
> > > > 1170: Function does not return a value.
> > > >
> > > > Is the checkData function checking both my customer and status
> > > > columns for '2' or do I have to (as I expect) enter in the
column
> > > > name I want to check in the code you provided?
> > > >
> > > > I appreciate your help and patience!
> > > >
> > > > --- In [email protected] 
<flexcoders%40yahoogroups.com><flexcoders%
40yahoogroups.com><flexcoders%

> > 40yahoogroups.com>, "Clint
> > > > Tredway" <grumpee@>
> > > > wrote:
> > > > >
> > > > > use a labelFunction to check the value and then do
something:
> > > > >
> > > > > private function checkData(item:Object,column:Object):String
{
> > > > > var retString:String;
> > > > > if(item['column'] == 2){
> > > > > retString="Return String";
> > > > > } else {
> > > > > retString = "Alt Return string";
> > > > > }
> > > > > }
> > > > >
> > > > > then set this as the labelFunction on that DataGridColumn
and
> > that
> > > > should
> > > > > get you going.
> > > > >
> > > > > On 2/12/07, jryano001 <jryan@> wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I'm very new to Flex and hope someone advise me on this or
> > tell
> > > > me if
> > > > > > it's even possible!
> > > > > >
> > > > > > My Flex application is pulling data using a php page. The
> > data is
> > > > > > then parsed into XML and is placed inside an
ArrayCollection
> > > > called
> > > > > > custData. My DataGrid is then using custData as it's
> > dataProvider.
> > > > > > This is all working and my Datarid displays my two colmuns
> > (cust &
> > > > > > status).
> > > > > >
> > > > > > What I need to be able to do though is to check the
values in
> > my
> > > > > > status column and if any of these change to '2' then
trigger
> > an
> > > > event
> > > > > > (at the moment this could just be to display some text).
> > > > > >
> > > > > > I know (unless someone tells me otherwise) that I need an
If
> > > > > > statement to check the values of status in my
ArrayCollection
> > but
> > > > I
> > > > > > need to know how you access just the values of status and
if
> > one
> > > > has
> > > > > > changed to '2' then to display the text.
> > > > > >
> > > > > > I'd really appreciate if someone could point me in the
right
> > > > > > direction. Thanks in advance. If it makes anything clearer
> > then my
> > > > > > code is below.
> > > > > >
> > > > > > ----------------------------------------------------------
> > > > > > ----
> > > > > >
> > > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > > > > > initialize="custRequest.send()">
> > > > > >
> > > > > > <mx:Script>
> > > > > > <![CDATA[
> > > > > > import mx.collections.ArrayCollection;
> > > > > > import mx.rpc.events.ResultEvent;
> > > > > >
> > > > > > [Bindable]
> > > > > > private var custData:ArrayCollection;
> > > > > >
> > > > > > private function resultHandler
> > > > > > (event:ResultEvent):void {
> > > > > > custData = event.result.cstatus.customer;
> > > > > > }
> > > > > > ]]>
> > > > > > </mx:Script>
> > > > > >
> > > > > > <mx:HTTPService id="custRequest"
> > > > > > url="http://localhost/FlexTest/retrieve.php";
> > > > > > result="resultHandler(event)"/>
> > > > > >
> > > > > > <mx:DataGrid dataProvider="{custData}">
> > > > > > <mx:columns>
> > > > > > <mx:DataGridColumn headerText="Customer"
> > > > > > dataField="cust"/>
> > > > > > <mx:DataGridColumn headerText="Status"
> > > > > > dataField="status"/>
> > > > > > </mx:columns>
> > > > > > </mx:DataGrid>
> > > > > >
> > > > > > </mx:Application>
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > http://indeegrumpee.spaces.live.com/
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > http://indeegrumpee.spaces.live.com/
> > >
> >
> >
> >
>
>
>
> --
> http://indeegrumpee.spaces.live.com/
>




--
http://indeegrumpee.spaces.live.com/

Reply via email to