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

Use row ID for hyperlink in Kendo Hierarchy Grid

3 Answers 185 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GenXisT
Top achievements
Rank 1
GenXisT asked on 24 May 2016, 07:10 PM

Hello, I have this sub-grid.  I'm trying to use the row ID (which appears fine on the actual row) .. but is null when I try to use it in the hyperlink inside a ClientTemplate

Any help?

 

<script id="criticalTopicsTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<DashboardViewModel>()
 .Name("grid_#=TopicID#")
 .Columns(columns =>
 {
 columns.Bound(cr => cr.CTID); // <-- CTID does appear here and on the grid
 columns.Bound(cr => cr.CTTitle).Title("CT Name");
 columns.Bound(cr => cr.CTStatus).Title("Status");
 columns.Bound(cr => cr.CTPercentComplete).Title("Percent");
 columns.Bound(cr => cr.CTEnd).Title("Target");
 columns.Bound(cr => cr.CTCertified).Title("Certified");
 columns.Bound(cr => cr.CTOwner).Title("Owner");
 columns.Bound(cr => cr.CTExecStakeholder).Title("Stakeholder");
 columns.Bound(cr => cr.OpenPRs).Title("Open PRs");
 columns.Bound(cr => cr.CompletedPRs).Title("Completed PRs");
 columns.Bound(cr => cr.OtherPRs).Title("Other PRs");
 columns.Command(command => command.Custom("Details").Click("showDetails")).Title("Critical Topic Details");
 columns
 .Bound(cr => cr.CTID)
 .Template(@<text></text>)
 .Title("Actions")
 .ClientTemplate("<a href='http://<link-info-here>/DispForm.aspx?ID=#=CTID#' target='_blank' class='k-button link'>View</a>" + // CTID = null
                 "<a href='http://<link-info-here>/EditForm.aspx?ID=#=CTID#' target='_blank' class='k-button link'>Edit</a>");  // CTID = null

 })
 .DataSource(dataSource => dataSource
 .Ajax()
 .Read(read => read.Action("GetCriticalTopics", "Hierarchy", new { title = "#=TopicTitle# " }).Data("filterOptions"))
 .PageSize(20)
 )
 .Pageable()
 .Sortable()
 .ClientDetailTemplateId("partnerTemplate")
 .ToClientTemplate()
)
</script>

3 Answers, 1 is accepted

Sort by
0
GenXisT
Top achievements
Rank 1
answered on 24 May 2016, 10:51 PM

I fixed it! It was a formatting issue.  New link looks like  this:

.ClientTemplate("<a href='http://<link-info-here>/DispForm.aspx?ID=\\#=CTID\\#' target='_blank' class='k-button link'>View</a>");

Needed to escape the ID.

0
Dimiter Madjarov
Telerik team
answered on 25 May 2016, 07:38 AM

Hello GenXisT,

You are correct, the # symbols which are part of the template syntax should be escaped in detail templates.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jorge
Top achievements
Rank 1
answered on 21 Dec 2018, 05:15 PM
I appreciate you shared how you fixed it! i avoided me a support ticket! kudos to you!
Tags
Grid
Asked by
GenXisT
Top achievements
Rank 1
Answers by
GenXisT
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Jorge
Top achievements
Rank 1
Share this question
or