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

Hyperlink not showing in grid column

5 Answers 829 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 10 Nov 2014, 08:25 PM
I have wired up a simple grid with some bound columns and one of those columns I'm trying to create a hyperlink.  Here is my code:

@(Html.Kendo().Grid(Model.CareAlerts)
    .Name("Alerts")
    .Columns(columns =>
    {
        columns.Bound(p => p.AlertDate).Title("Date").Format("{0:d}");
        columns.Bound(p => p.PatientName).Template(@<text>
            @Html.ActionLink(@item.PatientName, "Member", new { id = @item.PatientASID })
        </text>);
        columns.Bound(p => p.AlertSummary).Title("Message");
    })
                                        .Sortable()
                                        .DataSource(dataSource => dataSource
                                                .Ajax()
                                                .PageSize(20)
                                                .ServerOperation(false)
                                             )
            )

The second column is the column where I'm attempting to show the hyperlink.  Now, when I render the page, I can see the hyperlink for a split second before it disappears and I just see the text is supposed to be included in the link, but it is not linked after that.

Now, here's the funny thing:  If I remove the reference to kendo.aspnetmvc.min.js in my BundleConfig.cs file, the hyperlinks show up just fine, however, I get a "Script not included" error if I do this.

Any idea what I'm doing wrong?

5 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 12 Nov 2014, 08:43 AM
Hi Brad,


The reason for the problem is that the current Grid is using an Ajax dataSource i.e. the data is bound on the client side. This means that client templates should be used instead of server ones. You could check the following documentation page for further details.
E.g.
columns.Bound(p => p.ProductID).ClientTemplate(
    "<a href='" +
        Url.Action("ProductDetails", "Product") +
        "/#= ProductID #'" +
    ">Show Product Details</a>"
);

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Brad
Top achievements
Rank 1
answered on 12 Nov 2014, 12:27 PM
Dimiter,

Thanks for the response.  I was not meaning to use ajax and was merely following an example in the documentation when I set this up.  After reading your response, I was able to fix the problem by removing the following lines of code:

.DataSource(dataSource => dataSource
           .Ajax()
           .PageSize(20)
           .ServerOperation(false)
)

After removing this, everything seems to work fine.

Thanks,

Brad
0
Dimiter Madjarov
Telerik team
answered on 12 Nov 2014, 01:38 PM
Hi Brad,


You are correct, if an Ajax DataSource is not required, this is the correct way to resolve the problem.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
krishna
Top achievements
Rank 1
answered on 30 Mar 2015, 08:56 AM
Hi Dimiter ! How do i do it if i dont want hardcoding for "Show Product Details" part ?  I need to display the corresponding ProductID itself as the hyperlink for every new row!
0
Dimiter Madjarov
Telerik team
answered on 31 Mar 2015, 04:18 PM

Hello Gopikrishna,

In this case you could add another binding expression inside the template.
E.g.

columns.Bound(p => p.ProductID).ClientTemplate(
    "<a href='" +
        Url.Action("ProductDetails", "Product") +
        "/#= ProductID #'" +
    ">#= ProductID #</a>"
);

Regards,
Dimiter Madjarov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Brad
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Brad
Top achievements
Rank 1
krishna
Top achievements
Rank 1
Share this question
or