devextreme-angular icon indicating copy to clipboard operation
devextreme-angular copied to clipboard

Toolbar locateInMenu item onClick event

Open ArtemAlekhin opened this issue 9 years ago • 4 comments

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"?

ArtemAlekhin avatar Aug 13 '17 14:08 ArtemAlekhin

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 avatar Aug 14 '17 14:08 GoshaFighten

@GoshaFighten thank you! It works

ArtemAlekhin avatar Aug 14 '17 16:08 ArtemAlekhin

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.

Hello, How can you access the component context inside the callback function?

inmarktech avatar Feb 21 '20 12:02 inmarktech

You can access your Component, but you need to change the way you declare the method "refresh"

refresh = (event) => {
 ....
}

mickjol avatar Apr 08 '20 20:04 mickjol