--- In flexcoders@yahoogroups.com, "aramsdell2000" <aramsdell2...@...> wrote: > > I have put aside the thoughts of making fancy hyperlinks, now I am just > trying to understand events in the itemrenderer. I am ashamed to say that > even after searching this subject in the forum and googling it, I still find > myself struggling. > > I ended up trying a LinkBar as Tino suggested > > in the itemrenderer: > else if (column.dataField == "monitorlocations"){ > var linksArray:Array = String((data["monitorlocations"])).split("\n"); > var linkbarItemRendererFactory:ClassFactory = new ClassFactory(LinkBar); > linkbarItemRendererFactory.properties = {dataProvider:linksArray, > direction:"vertical",enabled:true }; > column.itemRenderer = linkbarItemRendererFactory; > column.setStyle("verticalGap",5); > column.addEventListener(ItemClickEvent.ITEM_CLICK, linkBarEventHandler); > > > Problem is that it seems like the click event on the button on the linkbar > never makes it to the linkBarEventHandler which is a function inside this > itemrenderer. I would at least think that this event would fire but setting a > breakpoint in this eventhandler fuction, I can tell it never makes it there. > The datagrid itemclick event doesn't even get called like it does in the > other columns, which I think is a good indication that I can bubble up the > linkbar clickItem event, I just can't figure out what I am doing wrong or > even how to capture in a debug session what happens on that click event.
If the linkBarEventHandler is a function inside the item renderer, I would expect you to get a compile error, since the function would be defined in a scope that the parent does not have access to, especially since when the factory is defined, no instances of it exist. If you want to have an event handler in the itemRenderer, attach the event listener inside the item renderer, either in MXML or in AS. The itemClick event of NavBar does not bubble, so the only place you can listen for it is inside the itemRenderer. This is a separate and distinct event from the ListBase itemClick, which will give you information about the entire object that is represented in the DataGrid row. You could potentially catch the NavBar itemClick in your renderer and create your own bubbling event that describes what happened. You could also just listen for a mouse click anywhere on the DataGrid and check the target property to see if the LinkBar is in some way a parent of whatever was clicked. HTH; Amy