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

[Solved] MVC3 razor and ClientTemplate colums

1 Answer 122 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.
Vincent Girard
Top achievements
Rank 1
Vincent Girard asked on 31 Mar 2011, 10:22 PM
Hi

I'm starting a new project in MVC3 and whant to use Razor view engine. Right now I'm having problems working with ClientTemplate.

Right now all <# Property #> returns [object Object] , why?

Here's my code and it was working in MVC2 project not in Razor :

@(Html.Telerik().Grid<User>()
                    .Name("Grid")
                    .Columns(colums =>
                     {
                         colums.Bound(c => c.Email);
                         colums.Bound(c => c.Id).Title(" ").HtmlAttributes(new { @class = "center-text" })
                             .ClientTemplate("<a id=\"deleteLink\" href=\"#\" title=\"Delete\" onclick=\"if(confirm('" + Strings.ConfirmDeleteAdmin + "')){ return deleteItem('<#=Id#>');} else { return false;};\">" + (@Id) + "<img src=\"Content/images/icons/cross.png\" alt=\"" + Strings.Delete + "\" /></a>"); 
                     })
                    .DataBinding(d => d.Ajax().Select(MVC.Admin.ListAjax().GetRouteValueDictionary()))
                    .Sortable()
                    //.Pageable()
)

Thx

1 Answer, 1 is accepted

Sort by
0
Vincent Girard
Top achievements
Rank 1
answered on 05 Apr 2011, 01:57 AM
I found out that my Id property was not a string and that's the source of my problem. 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
Vincent Girard
Top achievements
Rank 1
Answers by
Vincent Girard
Top achievements
Rank 1
Share this question
or