This is a migrated thread and some comments may be shown as answers.
Problem with ID value in client template
4 Answers 31 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter
Top achievements
Rank 1
Peter asked on 11 Dec 2011, 09:11 PM
hi,

I have a nasty issue.

This is a grid with a panel bar in a client template

@(Html.Telerik().Grid<ListHelperDiagnoseSet>().Name("DiagnoseSets")
    .Columns(cols =>
                 {
                     cols.Bound(m => m.Id).Hidden(true);
                     cols.Bound(m => m.OpDatum).Title("Datum");
                     cols.Bound(m => m.Id).ClientTemplate(
                         "<table><tr><td>" +
                         Html.Telerik().PanelBar().Name("DiagnoseSet<#= Id #>").Items(i =>
                                                        {
                                                            i.Add().Text("As1")
                                                                .LoadContentFrom("DiagnoseOpAs1", "Diagnose", new {idDiagnoseSet = "<#= Id #>"});
                                                            i.Add().Text("As2")
                                                                .LoadContentFrom("DiagnoseOpAs2", "Diagnose", new {idDiagnoseSet = " <#= Id #>"});
                                                            i.Add().Text("As3")
                                                                .LoadContentFrom("DiagnoseOpAs3", "Diagnose", new {idDiagnoseSet = " <#= Id #>"});
                                                            i.Add().Text("As4")
                                                                .LoadContentFrom("DiagnoseOpAs4", "Diagnose", new {idDiagnoseSet = " <#= Id #>"});
                                                        }
                             )
                             .ToHtmlString()
                         + "</td><td><div id = 'DSMtree<#= Id #>'></div></td></tr></table>");
                 }
 
           )                        
                         
The ID is used in the name of Panelbar, in the name of a div and in the action to load the content of the panels

Html.Telerik().PanelBar().Name("DiagnoseSet<#= Id #>").Items(i =>
   {
                                  i.Add().Text("As1")
                                   .LoadContentFrom("DiagnoseOpAs1", "Diagnose", new {idDiagnoseSet = "<#= Id #>"});
All seems t be working well, the panel bar and the div get the right name, when hovering over the panel the url looks OK.
But when selecting the panel something else is posted back to the controller. Instead of "1" (the value of the ID) %3C is posted back,
I can create an action which accepts a string, the content of that string is always "<". 

Is there a work around ? Am I doing something wrong ?

Using this client template as a details view works perfectly. But I don't want a details view, I want a template column...

kind regards

Peter



 

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Dec 2011, 11:59 AM
Hi Peter,

In order to make this work you should manually encode the template blocks in the PanelBar's routing:

"<table><tr><td>" +
 Html.Telerik().PanelBar().Name("DiagnoseSet<#= Id #>").Items(i =>
 {
     i.Add().Text("As1")
         .LoadContentFrom("DiagnoseOpAs1", "Diagnose", new { idDiagnoseSet = Html.Encode("<#= Id#>") });
     i.Add().Text("As2")
         .LoadContentFrom("DiagnoseOpAs2", "Diagnose", new { idDiagnoseSet = Html.Encode("<#= Id #>") });
     i.Add().Text("As3")
         .LoadContentFrom("DiagnoseOpAs3", "Diagnose", new { idDiagnoseSet = Html.Encode("<#= Id #>") });
     i.Add().Text("As4")
         .LoadContentFrom("DiagnoseOpAs4", "Diagnose", new { idDiagnoseSet = Html.Encode("<#= Id #>") });
 }
     )
     .ToHtmlString()
 + "</td><td><div id = 'DSMtree<#= Id #>'></div></td></tr></table>"

Regards,
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
0
Peter
Top achievements
Rank 1
answered on 14 Dec 2011, 08:49 AM
hi,

OK that should do it.
These Telerik <#= #> tags still remain enigmatic to me. I think I understand how to use them. But it is puzzling why you need to encode them in a column template and not in a details view template.
Is there more and deeper documentation on this ? All I know was scraped together from forum posts and undocumented exampled/
best

Peter
0
Rosen
Telerik team
answered on 15 Dec 2011, 01:44 PM
Hi Peter,

This is needed as the PanelBar's client object settings, including the content URLs will be URL encoded as expected. However, this will encode the template blocks within the URLs too, which will prevent correct evaluation. This is workaround by HTML encoding code blocks within the URLs.

Regarding the templates themselves, they are based on John Resig's micro templates, just with more ASP.NET friendly opening and closing symbols. 

Regards,
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
0
Peter
Top achievements
Rank 1
answered on 20 Dec 2011, 09:14 PM
Thanks you, that lifts the veil a little..
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Peter
Top achievements
Rank 1
Share this question
or