I think you need to do this via the underlying dataProvider, instead of trying to directly manipulate rendered controls.


On the edit event of the text control, set a property in the corresponding dataProvider item.  Have the item renderer respond to that value change by changing its state.




From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of flex8it
Sent: Monday, June 19, 2006 1:24 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Getting a DataGrid item renderer instance


More specifically, here's what I'm trying to change the viewState in
my itemRenderer when the DataGrid's textfield is edited. But in
order to do that, I need to somehow get an instance reference to my
renderer component. And nothing I've done seems to work...

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
verticalAlign="top" horizontalAlign="center"

import components.imgReset;
import mx.collections.ArrayCollection;
import mx.events.DataGridEvent;
import mx.controls.Alert;

public var choices:ArrayCollection = choices = new
{resetImage: "images/reset.png", fieldName: "Smalltown"},
{resetImage: "images/reset.png", fieldName: "Bigtown"},

private function changeRendererState(event:DataGridEvent) : void
// I can get the rowIndex and columnIndex for the renderer,
// but I don't exactly how to use them to get to the
renderer object...
Alert.show(event.rowIndex + ", " + (event.columnIndex - 1));

// I just want to get the renderer instance...
// First, there's a problem with my typecasting ??
// Second, there's no such thing as a row property on
// the DataGrid, but I really want there to be...
var RendererInstance:imgReset = imgReset(this.myGrid.columns

// Now I want to manipulate renderer instance
RendererInstance.currentState = 'showReset';
<mx:DataGrid id="myGrid"
itemEditEnd="changeRendererState(event)" >
<mx:DataGridColumn dataField="resetImage"
<mx:DataGridColumn dataField="fieldName"
editable="true" width="230"
headerText="Field Name" />

I'd sure appreciate some help on this conundrum.

Many Thanks,

--- In [EMAIL PROTECTED]ups.com, "flex8it" <[EMAIL PROTECTED]> wrote:
> I have simple datagrid with 2 columns and 2 rows like this:
> column 0 column 1
> -------- ---------
> image textfield
> image textfield
> Column 0 contains my ImageRenderer component.
> Column 1 contains the DataGrid's default item renderer and editor:
> text, textfield.
> First Problem:
> How do I identify/get a reference to a particular instance of my
> ImageRenderer from, say, column[0], row[1]?
> Second (related) Problem:
> How do I get the ImageRender instance that corresponds to the row
> the textfield that fires an event when edited?
> I've been wrestling with this problem for days now, and I just
> seem to get a grasp on the communication/eventing infrastructure
> that's probably necessary to pull this off. Please help.
> Thanks,
> Bruce


Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com

Web site design development Computer software development Software design and development
Macromedia flex Software development best practice



Reply via email to