This is a migrated thread and some comments may be shown as answers.

How to call an action from custom toolbar button

2 Answers 887 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Catherine
Top achievements
Rank 1
Catherine asked on 16 Jul 2018, 08:29 PM

Hi,

I was just wondering how to call an javascript function or controller action from a custom toolbar button on the grid. I notice that there's no .Action() or .Url(), ext attributes in the core html helpers.

Thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Accepted
Jason
Top achievements
Rank 1
answered on 17 Jul 2018, 03:34 AM

Hey there Catherine. You can give this a shot:

.ToolBar(toolbar => toolbar.Custom().Text("CustomCommand").HtmlAttributes(new { onclick = "customCom()" });

function customCom(e) {
        alert("Clicked!");
    }

 

Hope it helps.


0
Catherine
Top achievements
Rank 1
answered on 17 Jul 2018, 12:07 PM
Thanks Jason! I forgot the parentheses after the name of the function, which is why I couldn't get that to work...
Tags
Grid
Asked by
Catherine
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Catherine
Top achievements
Rank 1
Share this question
or