Describe the bug
When a click-event handler is set via the options.columns object on a Datagrid, the event handler code is executed outside the Angular zone.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The text should be updated but it is not.
zone.run() must be used (as commented in the code).
Version
Platform
Platform independent
I had thought about this when reviewing the ngZone changes made to the data grid component as any callback invoked directly from within the enterprise widget (such as the click handler on a column) would not be executed in the angular zone - as previously.
At the moment, the developer needs to understand the differences between events setup using the angular methods (such as @Output) and those using the enterprise widgets apis directly.
Ultimately, we should add adaptors to any incoming functions which maps them in/out of the angular zone as required. This should be done when setting the options on a widget, or when a relevant option is updated.
One other area to watch, is that change detection is no longer guaranteed to be fired when events are initiated from within the enterprise widget. It is the responsibility of the code handling the event to determine if anything needs to be updated, the alternative is that superfluous change detection cycles are fired which can seriously impact performance.
@tmcconechy @pwpatton what are you thoughts on adding "wrapper" code to ensure functions added via options (such as click) are in the correct zone?
I don't believe we should force change detection though, as this should be part of the callers contract.
How would this look in general? Would we be able to optionally do this in the zone or out?
For example, the click property on the column, we would wrap with a lambda that move it back into the angular zone when called. I think we have done this for others already, such as the source function.
I don't think this would be optional, as I can't see a reason not to swap back into the angular zone (in the click case).
i think this has been fixed on the attached PR
Most helpful comment
For example, the
clickproperty on the column, we would wrap with a lambda that move it back into the angular zone when called. I think we have done this for others already, such as the source function.I don't think this would be optional, as I can't see a reason not to swap back into the angular zone (in the
clickcase).