Hi there,


Just wanted to know if there is a better way to listen for an event in an
itemrenderer.



I’m working on a mobile app, which uses sqlite database and cairngorm
framework.



I have a list in my view which has my CustomRenderer.as as it’s
itemrenderer. This renderer initially loads basic data and displays it(data
is binded which we get in model).



Now, I also have a button on this renderer on clicking of which, I need to
get some more details by querying the db (I avoided this query on initial
load as it degraded the performance) and display this detailed data only on
this renderer on which I click the button.



Currently this is how I am achieving it:

1.       On click on button in the renderer, I am dispatching a cairngorm
event, which calls a command class, which is where I query db and receive
detailed data. This data is stored in a model variable.

2.       As soon as I store data in model variable, in next line I am
dispatching this event within same command class :
FlexGlobals.topLevelApplication.systemManager.dispatchEvent(*new*Event(ApplicationModelLocator.ON_DETAILED_DATA));

3.       I have added a listerner in the constructor of
CustomRenderer.as:
FlexGlobals.topLevelApplication.systemManager.addEventListener(ApplicationModelLocator.OVERVIEW_TREND_CLICK_DATA,
onOverviewTrendClickData, *false*,0,*true*);

4.       In onOverviewTrendClickData function I build the extra UI that is
needed to show the detailed data.



However, in this approach, the onOverviewTrendClickData function gets
triggered many times(based on number of renderer items that are displayed
in the list).



Can you kindly let me know if there is a way I can avoid it? Or any other
approach to achieve this?





Warm regards,

Deepak

Reply via email to