Kendo ui grid mvc action link column template

The following code works fine in development, as soon as I deploy to the web server, he said that he could find the file directory. I need to modify the .client template so that it is not hardcoded as before. Therefore, if we deploy a server on which the name of the top folder differs or the hierarchy changes, it still finds the page.

I thought using @ Url.Action, but not sure how to implement in .CLientTemplate in this case

columns.Template(@<text> @Html.ActionLink(@item.FirstName, "Index", "Summary", new { testId = @item.FirstName }) </text>) .ClientTemplate("<a href='/Summary/Index/?testId =#= TestId #'>#=FirstName#</a>").Title("First Name"); 
+6
source share
4 answers

Something like this should do:

 .ClientTemplate("<a href='" + Url.Action("Index", "Summary", new { testId = "#=TestId#" }) + "'>#=FirstName#</a>") 
+6
source

I got this good job

 columns.Bound(a => a.Id) .Title("Action") .Filterable(false) .ClientTemplate( "<a href='" + Url.Action("ActionName", "Controller") + "/#= Id #'" + ">View</a>" ); 

I needed an additional column and link button field to go to the client information page. I do not need a filter parameter for this column, and therefore I delete it with Filterable(false) . You can also specify the content of the link and the column heading as described above. This value "/#= Id #'" is the one I pass to the controller action method.

+6
source

If you use server binding (unlike ajax) and Razor as your viewing mechanism, here is an example. I need a link, for example / Controller / Action / Id, where Id is obtained from the model property. Please note that @item denotes an instance of the model that is currently being processed by the grid.

 columns.Template(@<text>@Html.ActionLink(AbaScore.Resources.App.Edit,"ACTION", "CONTROLLER", new { @item.Id }, null)</text>) 
+3
source

I saw 87 different examples of this, and none of them worked. This is what I finally did, and it worked, and it's just like hell.

 columns.Bound(p => p.member_id) .ClientTemplate("<a href='/members/details/#=member_id#'>Details</a>") ; 
0
source

All Articles