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

Custom toolbar command, how to avoid redirect?

1 Answer 307 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 Dec 2012, 04:38 PM
I'm new at this, so bear with me.

I have a Grid with a toolbar that has a Save() command defined.  I also want to define an Approve command, which does backend processing in a similar manner as Save but with a different stored procedure.

Save works fine by simply having toolbar.Save() to create the button, and then datasource.Update("UpdateData", "Controller") to define the backend call.

For Approve, I have tried to do toolbar.Custom().Text("Approve").Action("Approve", "Controller").  This calls the backend Approve method just fine.  But it also redirects the page to a /Approve page, which I don't want.  I want it to function like Save() does with my Ajax() datasource, and not redirect the browser anywhere.

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 11 Dec 2012, 08:55 PM
Nevermind, figured it out.  Didn't realize this was more an MVC and jQuery thing than a Kendo thing.

I created a JavaScript function called callApprove(), which does a $.ajax() to the URL which would call my Approve() method (according to MVC default routing rules).  Then my custom toolbar thing looked like: toolbar.Custom().Text("Approve").Url("#").HtmlAttributes(new { onclick = "callApprove()" });

That did everything it was supposed to.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Share this question
or