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

[Solved] Using Template & ClientTemplate with grid

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff
Top achievements
Rank 1
Jeff asked on 05 Oct 2011, 09:00 PM

I've got the grid working, paging works. I would like to be able to specify my ClientTemplate as I do with my columns.Template (i.e. Use Url.Action and Url.Content). I can't get the doggone syntax to work correctly.
Here's the top of my view file:

@model List<SW_Admin_MVC.Models.ParticipantInfo>
 @{ Html.Telerik().Grid(Model).Name("ResultsGrid").Columns(columns =>{

columns.Template(

@<text>  

<a href="@Url.Action("HideRowPerm", "Home", new {id = item.MemberKey, useMock = false.ToString()})" onclick="javascript:return ConfirmHiding();" >

 <img src="@Url.Content("~/Content/themes/base/images/hide.png")" alt="Hide Perm" style="border: none;" /></a>

</text>)

.HeaderTemplate(@<text>Hide Row  <br />Perm </text>)

.ClientTemplate( 

@"<a href=""/Home/HideRowPerm/<#= MemberKey #>""><img src=""/Content/themes/base/images/Hide.png"")></a>")

 .Width(15).HeaderHtmlAttributes( 

new { style = "text-align:center" }) .HtmlAttributes( new { style = "text-align:center" });text>)

 

This works, except for the fact that on the web server the site is held in a sub-directory, so the image and link locations of the ClientTemplate don't resolve. I want to have the ClientTemplate looko like it does for columns.Template (i.e. using Url.Action and Url.Content) but can't seem to get the syntax to work. Any help would be appreciated. Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 06 Oct 2011, 08:11 AM
Hi Jeff,

Please take a look at this online demo, which demonstrates similar to the requested functionality.

Greetings,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or