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

Add a link in DetailTemplate

5 Answers 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
yann
Top achievements
Rank 1
yann asked on 01 Aug 2018, 01:43 PM

Hello,

I would like to know if i can add an ActionLink in a column in my DetailTemplate: 

The only way I've found is by using a Template , for exemple : 

 

 

.Columns(col => {

      col.Bound(p => p.Etat).Template(@<text>@Html.ActionLink("Edit", "Edit")</text>);

})

 

 

But like i'm already in a DetailTemplate , i get an error when i try to do this :

 

 

.DetailTemplate(
            @<text>
             @(Html.Kendo().Grid<Affaire>()
                       .Name("Affaires_" + item.Id)
                       .Columns(col => {
                                                    col.Bound(p => p.Name).Template(@<text>@Html.ActionLink("Edit", "Edit")

             </text>)

 

Is there another way to make this link work ?

Thanks

 

5 Answers, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 03 Aug 2018, 01:01 PM
Hi Yann,

You can create action Links inside the DetailTemplate using ClientTemplate() method and omitting the <text> declarations and @ signs.
.DetailTemplate(@<text>
    @(Html.Kendo().Grid<KendoMVC.Models.OrderViewModel>()
        .Name("Affaires_" + @item.Id)
        .Columns(col =>
        {
            col.Template(x => x).ClientTemplate(Html.ActionLink("Edit", "Home", new { id = item.Id }).ToHtmlString());
        })
    )
</text>)

The template() method was designed for the first level block, it will not have any effect in a nested template.

I hope this will prove helpful.

Kind Regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
yann
Top achievements
Rank 1
answered on 08 Aug 2018, 03:10 PM

Thanks you , it worked well.

I have another question however :

In this situation ,  if I have different class for the parent and the child , how could I use the variables of my child ? (for exemple, in the action link attributes )

 

I've tried new { id = item.Id } but item is the parent , so i tried "#=Id#" , "//#=Id//#" , "#:Id#" and so on but i can't find the one who works…

Thank you

 

 

0
Attila Antal
Telerik team
answered on 10 Aug 2018, 11:55 AM
Hi Yann,

The first method you've tried is the correct one ( #= FieldName # ). If you open the developer tools of the browser and refresh the page, do you receive error messages?

You may also double check the datasource to ensure that the field "Id" exists.

Example of evaluating data:
.DetailTemplate(@<text>
    @(Html.Kendo().Grid<KendoMVC.Models.OrderViewModel>()
           .Name("Affaires_" + @item.OrderID)
           .Columns(col =>
           {
               col.Bound(p => p.Freight);
               col.Template(x => x).ClientTemplate(Html.ActionLink("#=Shipname#", "ShipName", "#= OrderID #").ToHtmlString());
           })
           .DataSource(dataSource => dataSource)
    )
</text>)

I look foward to hearing from you.

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
yann
Top achievements
Rank 1
answered on 13 Aug 2018, 09:56 AM

Hi Attila,

Your example works I was just using Bound and not Template.

Thank you for your reply and your time.

 


0
Attila Antal
Telerik team
answered on 15 Aug 2018, 08:12 AM
Hi Yann,

I am glad the issue has ben resolved!

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
yann
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
yann
Top achievements
Rank 1
Share this question
or