Sometime back I had written an article – JET – custom event wrappers – on how to add some custom information to an event raised by a component and then throw the event wrapped under your own custom event.
This article is just an extension of the same thought, which demonstrates how effectively you may use the above concept to solve your problem. Here is the use-case:
We have an oj-chart component, which has a context-menu. Depending on the bar or pie slice which fired the context menu, we need to capture the chart data and act accordingly when the user clicks on any of the menu options.
However, the action event (on-oj-action) from oj-menu does not capture any information regarding the chart series or group. But, oj-menu has a beforeOpen event (on-oj-before-open), which fires just before the context menu pops up and, more importantly, which captures all the data that we need.
So how do we make use of this event to solve our problem?
Step 1: Context menu fires beforeOpen event. We get chart related data from this event.
Step 2: We store the chart data in a variable.
Step 3: Context menu option click fires action event. This event is captured, the extra information is attached from the variable in step 2, and thrown again as a custom event. Read the complete article here.
For regular information become a member in the Developer Partner Community please register here.