toolbar item onclick

not one of the demos, examples or documentation items show how to set the onclick of a toolbaritem ... 

if its @onclick(nameofcodebehindprivatevoid) what args are sent thro ?



3 Replies 1 reply marked as answer

PN Praveenkumar Narasimhanaidu Syncfusion Team February 22, 2021 12:43 PM UTC

Hi Kevin, 

Greetings from Syncfusion support..! 

We have validated your requirement and let you know that currently there is no native @onclick support in toolbar component but we have our own OnClick event for toolbar items click action. We can pass ClickEventArgs in it and for the same we have prepared a sample which can be downloaded from following link. 


@using Syncfusion.Blazor.Navigations 

<SfToolbar> 
    <ToolbarItems> 
        <ToolbarItem Text="Cut" OnClick="ItemClick"></ToolbarItem> 
        <ToolbarItem Text="Copy"></ToolbarItem> 
        <ToolbarItem Text="Paste"></ToolbarItem> 
        //To separate the Toolbar items 
        <ToolbarItem></ToolbarItem> 
        <ToolbarItem Text="Bold"></ToolbarItem> 
        <ToolbarItem Text="Unde rline"></ToolbarItem> 
        <ToolbarItem Text="Italic"></ToolbarItem> 
        <ToolbarItem Text="Color-Picker"></ToolbarItem> 
    </ToolbarItems> 
</SfToolbar> 

@code{ 
    public void ItemClick(ClickEventArgs args) 
    { 
        // Triggers whenever the toolbar item has been clicked 
    } 

We have showcase this click action in our following UG. 

Kindly try the above solution and get back to us if you need any further assistance. 

Regards, 
Praveenkumar. 


Marked as answer

KV kevin vickers February 22, 2021 12:55 PM UTC

hey thanks 

i note that your example here is ...

 OnClick="OnItemClick"


but in the sample .. 

 OnClick="@OnItemClick"


NR Nevitha Ravi Syncfusion Team February 23, 2021 11:41 AM UTC

Hi Kevin, 

Thanks for your update. 

There is no major difference in using @ and not using it, mostly we will use @ in lamda expressions. So you can use without using @ as in the shared code snippet. Please refer to the following links. 

Please get back to us if you need any further assistance. 

Regards, 
Nevitha 


Loader.
Up arrow icon