0
votes

I haave some data in item renderer and need to use in application level. Example:- i have a button itemRenderer in datagrid. when i click on the button i have to carry some data to dispatch event at application level. So how to get the item renderer data into the mail application. I had written a custom Event and listen the event in main application. But it does not work. Can anyone have a better idea to solve it.

2

2 Answers

1
votes

if you want to listen a event from itemrender to outside component then event's bubble value must be true, default its value is false so you have to true after your custom variable....

this.dispatchEvent(new customEvent(CutomEventType, CustomVariable, **true)**);

Good luck!

0
votes

You can simply access the dataGridId.selectedItem to get whatever item is selected without an event, however you won't know when it changes. If you only need to know the value after some user action you can use the selectedItem property. If you need to know when it changes using an event is definitely the best way to go, as JK Patel states it must be marked to bubble if you're not listening for it directly on the object that dispatches it... instead of a custom event if you dispatch the event from the renderer itself, you can use event.target.data to get a handle on the data without a custom event.