Toolbar locateInMenu item onClick event
Hello, I'm trying to configure the toolbar with dxi-item's as follows:
<dx-toolbar>
<dxi-item location="before">
<dx-button type="back" text="Back" (onClick)="gotoList()"></dx-button>
</dxi-item>
<dxi-item location="before">
<dx-button type="default" icon="save" text="Save" (onClick)="save()"></dx-button>
</dxi-item>
<dxi-item locateInMenu="always" text="Refresh" (onClick)="refresh()"></dxi-item> <-- DON'T WORK
</dx-toolbar>
How I can bind onClick event to dxi-item with locateInMenu="always"?
In this case, onClick is not an event. It's a callback function. So, you need to run it using square brackets:
<dxi-item locateInMenu="always" text="Refresh" [onClick]="refresh"></dxi-item>
See the Plunker sample that illustrates this.
@GoshaFighten thank you! It works
In this case,
onClickis not an event. It's a callback function. So, you need to run it using square brackets:<dxi-item locateInMenu="always" text="Refresh" [onClick]="refresh"></dxi-item>See the Plunker sample that illustrates this.
Hello, How can you access the component context inside the callback function?
You can access your Component, but you need to change the way you declare the method "refresh"
refresh = (event) => {
....
}