I haven't done this from a custom header... so sorry if this is way off base. But, perhaps you could dispatch an event with bubbles = true from the click handler rather than trying to call a method. Just make sure you register as a listener (on the datagrid) for the event type that you are dispatching. Seems the event should bubble out to you.

hth
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com



Sajid Hussain wrote:
hey .....
I want to add checkbox control in datagrid header ,I alredy render tht checkbox but problem is that I m not able to call function from on that click even I tried parentDocument.callMyfunction(); ..its giving me error but the same method I have applied to rows checkbox its working but header its not wroking ...
but with application refrence I m able to calllllll .....

ANy help

----- Original Message ----
From: rueter007 <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, December 19, 2007 10:47:05 AM
Subject: [flexcoders] Re: DataGrid ItemRenderes - How to access the {data} from the datagrid

You are doing a few things wrong here. use the following source in
your itemrenderer. mxml file

<?xml version="1.0" encoding="utf- 8"?>
<mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml <http://www.adobe.com/2006/mxml>"
xmlns:local= "*" >

<mx:Script>
<![CDATA[
import mx.events.ListEvent ;

[Bindable] private var dp:Array = [
{ symbol: "ADBE", name: "Adobe Systems Inc.", price: 49.95, bold: true },
{ symbol: "MACR", name: "Macromedia Inc.", price: 39.95, bold: false },
{ symbol: "MSFT", name: "Microsoft Corp.", price: 25.95, bold: true },
{ symbol: "IBM", name: "IBM Corp.", price: 42.55, bold: false }
];

private function changeHandler( event:ListEvent) :void
{
var item: Object = event.itemRenderer. data;

item.bold = !item.bold;
dg1.dataProvider. itemUpdated( item);
}

// Sets the styles to display the DataGrid Items
private function computeStyles( data:Object, column:DataGridColu mn):Object
{
var o:Object = new Object();

var bold:String = data["bold"] ;
if (bold == "true")
{
o.bold = true;
} else {
o.bold = false;
}

return o;
}

]]>
</mx:Script>

<mx:DataGrid id="dg1" dataProvider= "{dp}"
change="changeHandl er(event) " paddingTop=" 0" paddingBottom= "0"
verticalAlign= "middle" >
<mx:columns>
<mx:DataGridColumn headerText=" Name" dataField="name" width="140"/ >
<mx:DataGridColumn headerText=" Symbol" dataField="symbol" width="60" />
<local:CustomColumn stylesFunction= "computeStyles" headerText=" Price"
dataField="price" itemRenderer= "CustomRenderer" />
</mx:columns>
</mx:DataGrid>

</mx:Application>

The most important issue here is that the changeHandler is modifying
the dp array which is not the same as the dataprovider of the grid.
you need to get a handle to the actual item in the grid's dataprovider
using the event.itemrenderer. data property and make changes to it. I

HTH

- venkat
http://www.venkatj. com <http://www.venkatj.com>

--- In [EMAIL PROTECTED] ups.com <mailto:flexcoders%40yahoogroups.com>, "m.frigge" <[EMAIL PROTECTED] .> wrote:
>
> Hey Mark,
>
> I'm struggling with itemRenderers too. First of all here
>
<http://blogs. adobe.com/ aharui/2007/ 03/thinking_ about_item_ renderers_ 1.h\ <http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.h>> tml> is a link to Alex's blog speaking about itemRenderers and showing
> some nice examples. In the BlinkWhenDataChange d example he is changing
> Background settings. I tried to adopt his itemRenderer and change it so
> that it checks a data value and sets the textFormat depending on what
> value the data has. This
> <http://16-bits. com/ItemRenderer /ItemRenderer. html <http://16-bits.com/ItemRenderer/ItemRenderer.html>> is how far i came.
> I toggle the value on change, so when you click it the style changes. My
> only Problem is that it doesn't work anymore after sorting the dataGrid
> by one of its columns. Maybe we can work on this together :-).
>
> Cheers, Max
>
> --- In [EMAIL PROTECTED] ups.com <mailto:flexcoders%40yahoogroups.com>, "oneproofdk" <mark@> wrote:
> >
> > Hi.
> > In a itemrenderer I'd like to access a {data} value in a Script in the
> > itemrenderer. I just can't figure out how to do this.
> >
> > I have an ArrayCollection as the dataprovider for the DataGrid.
> > In a Column, I sue a itemrenderer "status"
> >
> > Inside renderer.status. as I have a VBox, with a init() function.
> > Inside init I'd like to test if "data.repeating" != null and if so,
> > set a label to a specific value, if not null, set to another value.
> >
> > <vbox><script> </script> <label/>< /vbox>
> >
> > Please - can anyone help me out with an example on how to accomplish
> > this, I hope, simple task.
> >
> > (The reason for using a VBox was that I had my hopes for setting the
> > background color also, so if != null color=XX + text = XX etc.
> >
> > Thanks for your time
> > Mark
> >
>



------------------------------------------------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search. <http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>

Reply via email to