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

Can't get custom command button to invoke an action in my controller.

16 Answers 2412 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 01 Sep 2012, 07:14 PM
Hello,

I've added a custom command, "Details", to the rows in my grid so a user can view the details about the row.  When clicked, I want it to access the Details action in my HomeController.  However, when I build my solution, I receive the following error message:

"Custom command routes is available only for server binding."

Can someone please tell me how I can correct this issue?  My ulitimate goal is to create custom command buttons for Add, Edit, Delete, and Details, so my existing Views will be presented, rather than using the inline editing.  I need to create these custom buttons because the default command buttons don't seem to permit routing to my Views.  Anyway, I would appreciate your help.

Thanks,
Mike

      .Columns(columns =>
      {
          columns.Command(p => { p.Custom("ViewDetails").Action("Details", "Home").Text("Details"); }).Width(160);
          columns.Bound(p => p.CustomerId)
      })

16 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 05 Sep 2012, 02:31 PM
Hi Mike,

As the messages describes the ActionLink command is available only for Server binding. If you want to create a buttom with which points to a different view when using Ajax binding you can use a template column with a hyperlink inside of it.
columns.Template(@<text></text>).ClientTemplate("<a href='"+Url.Action("Edit","Home")+"/#=PersonID#'>Edit</a>");



Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Paul
Top achievements
Rank 1
answered on 14 Jul 2014, 09:57 PM
Why is that not shown as example here then

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-custom-commands.html#AjaxCommand

Very frustrating looking to the documentation for any sort of answers or guidance.
0
Neer
Top achievements
Rank 1
answered on 03 Sep 2014, 02:41 PM
I agree!!! I only found this forum post, because I Googled "custom command routes is available only for server binding."
0
Dimiter Madjarov
Telerik team
answered on 04 Sep 2014, 07:53 AM
Hello guys,


The topic is covered in the following FAQ section of the documentation.

Have a great day!

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
James
Top achievements
Rank 1
answered on 30 Dec 2014, 04:49 PM
I can not add the @<text></text> in the template or I get a nesting error:
Error 1 Inline markup blocks (@<p>Content</p>) cannot be nested.  Only one level of inline markup is allowed.  How can the Url.Action be drawn in an Ajax loaded child grid?
0
Atanas Korchev
Telerik team
answered on 02 Jan 2015, 11:17 AM
Hello,

You can try this:

.ClientTemplate("<a href='" + Url.Action("Index", "Home") + "'>Home</a>");


Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jim
Top achievements
Rank 1
answered on 01 Feb 2015, 06:07 PM
hey great help, but what if I want to put a command button instead of an actionlink?  basically i want a command button that will call the Edit controller action.
0
Atanas Korchev
Telerik team
answered on 02 Feb 2015, 09:02 AM
Hello,

You should use a Command column to get the built-in edit command:

columns.Command(commands => commands.Edit());


Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
srinivasa rao
Top achievements
Rank 1
answered on 18 Dec 2015, 06:23 PM

I am new to KendoUI Grid Can let me know From where PersonId Came from.

I am trying but Parameter is not passing to the action method.

Could you help me no this.

0
Dimiter Madjarov
Telerik team
answered on 23 Dec 2015, 09:27 AM

Hello Srinivasa,

PersonID refers to the id property from the Grid model and is appended to the link in the template.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Deon van Staden
Top achievements
Rank 1
answered on 23 Jun 2016, 12:01 AM

I am trying to use the example above:

columns.Template(@<text></text>).ClientTemplate("<a href='"+Url.Action("Edit","Home")+"/#=PersonID#'>Edit</a>");

but keep on receiving the following error whenever I have @<text></text>

"Cannot convert lambda expression to type 'string' because it is not a delegate type"

Why is it that I cannot use @<text> in my Razor code to explicitly define this content?

0
Dimiter Madjarov
Telerik team
answered on 23 Jun 2016, 08:31 AM

Hello Deon van Staden,

The provided sample code looks correct. I assume it is not the reason for the mentioned error.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Matthew
Top achievements
Rank 1
answered on 10 Nov 2016, 03:45 PM
How does this help I still get the same error
0
Dimiter Madjarov
Telerik team
answered on 14 Nov 2016, 09:22 AM

Hello Matthew,

Please provide further details about the Grid configuration on your end and if possible send us an isolated runnable example, so we could inspect it locally and provide assistance.

Regards,
Dimiter Madjarov
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Gary
Top achievements
Rank 1
answered on 17 May 2017, 04:12 PM

I was also trying to get the custom command to work and getting the server binding error.  Here is a column that calls an action that looks like the kendo edit button vs. a link:

columns.Template(@<text></text>).ClientTemplate("<a href='" + Url.RouteUrl("Default", new { controller = "InsertYourControllerName", action = "InsertActionName" }) + "/#=InsertID#' class='k-button k-button-icontext'><span class='k-icon k-i-edit'></span>Edit</a>").Width(125);

0
Boyan Dimitrov
Telerik team
answered on 22 May 2017, 01:13 PM

Hello Gary,

Could you please provide the error you are facing? 

Regards,
Boyan Dimitrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Paul
Top achievements
Rank 1
Neer
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
James
Top achievements
Rank 1
Atanas Korchev
Telerik team
Jim
Top achievements
Rank 1
srinivasa rao
Top achievements
Rank 1
Deon van Staden
Top achievements
Rank 1
Matthew
Top achievements
Rank 1
Gary
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or