• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

How to pass data to a component that is used as an itemRenderer

I have a component, and when used in the normal sense, passing data to it is not a problem. Let's say I have a component called MyComponent which has one public property called dp (for dataProvider). When using this component normally, passing data to it is easy:

<v:MyComponent dp="{some array collection}"/>

 But I now want to use this component as an itemRenderer in a datagrid. Since an item renderer is defined like:

<mx:DataGridColumn itemRenderer="MyComponent"/>

I'm not sure how to pass data to it anymore.

I also want to keep this component loosely-coupled, meaning I don't want to use mx.core.Application.application from within the component to access data outside it.

Does anyone know how I can pass data to a component being used as an itemRenderer and still keep it loosely-coupled?

  • 2
1 Solution
zzynxSoftware engineerCommented:
var myRenderer:ClassFactory = new ClassFactory(MyComponent);
myRenderer.properties = { dp: yourArrayCollection };
myDataGrid.itemRenderer = myRenderer;

cf http://livedocs.adobe.com/flex/3/langref/mx/core/ClassFactory.html
elepilAuthor Commented:
I rated your answer "Partially", only because it took me a few moments to figure out the context, but the answer is definitely accurate, and the link to the Adobe's livedocs makes it complete. Thank you.
zzynxSoftware engineerCommented:
Thanx 4 axxepting

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now