2015-06-11 18 views
1

因此,我有一個使用'Hierarchical'機制的Kendo網格。當我來到我的客戶模板部分,我這樣做:如何使用Kendo Grid上的客戶端模板中的項目的ID創建超鏈接

.Columns(column => 
        { 
         column.Bound(o => o.Id).Width(110); 
         column.Bound(o => o.Title); 
         column.Bound(model => model.Id) 
            .ClientTemplate(String.Format("<a href=\"{0}\" data-title=\"View Stuff\" class=\"stuff\"><i class=\"glyphicon glyph-btn directory\">Stuff</i></a>", Url.Action("Details", "Stuff", new { Id = "#=Id#" }))) 
            .Width(40) 
            .Title("View");      
        }) 

當我跑這件事,在ID(第一列)正確出來 - 通過其正確的ID識別作爲組項目。但是,當我嘗試在超鏈接中使用「#= Id#」時,它總是指我單擊以顯示組(客戶端模板)的原始項目的Id。

有誰知道如何在超鏈接中使用組項的Id(即第一列的輸出)?

在此先感謝

回答

2

如果你看一下這個問題的答案telerik question

您需要使用您的\\#Id\\#方法ChildTemplate內註明你所訪問當前的子元素,而不是父母。將您的語法更改爲以下內容:

.ClientTemplate(String.Format("<a href=\"{0}\" data-title=\"View Stuff\" class=\"stuff\"><i class=\"glyphicon glyph-btn directory\">Stuff</i></a>", Url.Action("Details", "Stuff", new { Id = "\\#=Id\\#" }))) 
相關問題