Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

column template kendo ui grid mvc action link

The following code is working fine in development, as soon as i deploy in web server it said could find file directory. I need to change the .client template so its not hard coded like before. So if we deploy to the server where the Top folder name different or the hierarchy change, it still find the page.

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

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");
like image 358
Supermode Avatar asked Dec 05 '12 03:12

Supermode


Video Answer


2 Answers

Something like this should do:

.ClientTemplate("<a href='" + Url.Action("Index", "Summary", new { testId = "#=TestId#" }) + "'>#=FirstName#</a>")
like image 55
Oxon Avatar answered Oct 14 '22 16:10

Oxon


I got this one working fine

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

I needed an extra column and a link button field for go to details page of a customer. I don't need filter option for this column and that is why I remove it using Filterable(false). Also you can give the link content and column header as above. This value "/#= Id #'" is the one I pass to the controller action method.

like image 44
Dushantha Avatar answered Oct 14 '22 17:10

Dushantha