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

[Solved] ClientTemplate does not work correctly with Razor View Engine

3 Answers 268 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.
Hui
Top achievements
Rank 1
Hui asked on 05 Mar 2011, 03:40 PM
Hi. I am using Telerik Extensions for ASP.NET MVC Open Source Version: 2010.3 1318 (Jan 18, 2011). I used MVC extension with ASPX before and I like this very much. But now with this new version I found a issue here.

I am using Razor view engine right now. My codes look like:
1) columns.Bound(o => o.Id).ClientTemplate("User <#= Id #>")
2) columns.Bound(o => o.Id).ClientTemplate(Html.ActionLink("Edit", "Edit", "User", new { id = "<#= Id #>" }, null).ToHtmlString())

First line works great.
Second line worked great with ASPX view engine before. But now with Razor I never retrieved the data from "<#= Id #>" if I put it as a parameter of a server side method. 

Anyone can help? Thanks a lot.

3 Answers, 1 is accepted

Sort by
0
Kevin Burandt
Top achievements
Rank 1
answered on 05 Mar 2011, 05:20 PM
columns.Template(m => @Html.ActionLink("Edit", "Edit", "Customer", new { id = m.Id })
       .Width(50)
       .Title("Edit")
       .HtmlAttributes(new { style = "text-align:center" });


// Client template

columns.Template(s => Html.ActionLink("Edit", "Edit", new { s.Id }))
.ClientTemplate("<a href=\"" + Url.Action("Edit", "Customer") + "/<#= Id#>\">Edit</a>")
.Width(50)
.Title("Edit");


0
Hui
Top achievements
Rank 1
answered on 07 Mar 2011, 07:39 AM
Thanks for reply. I am using AJAX binding so the columns.Template does not work for me. By using ClientTemplate I also came up with a familiar solution. But I do need to call a server side method to format the content. Then what can I do? That means I do need use the value of this column as a parameter into a server side method by using AJAX binding. Any advise? Thanks again.
0
Vincent Girard
Top achievements
Rank 1
answered on 06 Apr 2011, 04:50 PM
I had the same problem, I found out that my Id property was not a string and that's the source of my problem, don't know if it's the same for you but maybe it could help! What I did is I'm returning a simpler object to my grid that is built from the real object so that my Id property is a string and it works perfectly.
Tags
Grid
Asked by
Hui
Top achievements
Rank 1
Answers by
Kevin Burandt
Top achievements
Rank 1
Hui
Top achievements
Rank 1
Vincent Girard
Top achievements
Rank 1
Share this question
or