This content has been marked as final. Show 4 replies
you can define a customized object class extending displayobject and add that object to your canvas
as to accessing the value, i think following code will work
yourObj = yourCanvas.getChildAt(index);
yourVal = yourObj.yourProp;
//yourProp is defined in your class and storing the value from your data source
"Lvw2000" <firstname.lastname@example.org> wrote in message
> Yes... another ItemRenderer related question...
> So I have this advancedDataGrid of which I dynamically generate the
> columns in
> actionscript. Each of these columns get their own datafield.
> This code works well, since all the data displays nicely where I want it
> to be.
> However, in the columns there are numbers from like 0 to 10, these are put
> there by the default itemrenderer by using the datafield. Instead of just
> displaying these numbers, I'd like to use a canvas as an itemrenderer to
> something in the box based on the value of the number. So all I need to
> in my Canvas is the value that is parsed by the datafield.
> I thought to do so by overriding public function set
> But what does value contain?
It contains the information needed for the entire row. Just put a break
point in the code in your override function and then run the application in
debug mode. Use the variables window to inspect the value.
> I tried doing something with it but I keep
> getting errors.
Are the errors related to the value or are they related to something else,
such as trying to set properties on subcomponents that have not been
> Does value just contain the entire dataProvider? Or is there a
> way to acces just the number that would be put on that position in the
> grid if
> I wouldn't be using a custom itemrenderer at all?
Look at implementing IDropInListItemRenderer and then look at
Thanks a lot for your help people. My first approach was with a DropInListItemRenderer, but that appaers to be mostly usefull if you need to know the state of the entire grid, which isn't the case here.
I've come up with another possibility myself. Instead of overriding set data, I override updatedisplaylist. Then I can find the piece of info I need in may dataprovider based on a property I've set at the time I add the renderer to the row. So basically I've found a way to do what I want, but it's very buggy atm. Collapsing and expanding rows from the filetree at the left (the dataprovider is hierarchicaldata) renders to a lot of undesired effects with data moving to wrong rows and all...
But it's nearly impossible to explain what exactly happens on this forums.
Lots of thanks to you and happy coding! :)
If the visual characteristics of your ItemRenderer depend on the values in the dataProvider items (this is usually the case, and is why they are called 'item renderers'), the the set data() and "commitProperties" functions are critical. You must set the visual state when the data changes (when commitProperties is called, actually). "...data moving to wrong rows ..." sounds like you are not doing that. Read up on renderer "recycling".
The "value" argument in set data() is a reference to the dataProvider item for the row that the renderer is on. How you access the data in that item depends on what the item object data type is (Object, XML, custom VO,...)
Unless you are an expert, do not try to build an itemRenderer from scratch. Instead, find one and modify it.