2010-06-15 52 views
2

我使用Telerik的網格來呈現由以下用戶收到的備忘錄是代碼ActionLink的問題與客戶端模板Telerik的MVC電網

<%Html.Telerik().Grid<UserManagement.Models.SentMemos>() 
    .Name("ReceivedMemos") 
    .Sortable(sorting => sorting 
     .OrderBy(sortOrder => sortOrder.Add(o => o.MemoDate).Descending()))   
    .DataBinding(dataBinding => dataBinding 
     //Ajax binding 
    .Ajax() 
    //The action method which will return JSON 
    .Select("_AjaxBindingReceivedMemos", "OA") 

     ). 
     Columns(colums => 
     { 
      colums.Bound(o => o.MemoID).ClientTemplate(Html.ActionLink("Reply", "ReplyMemo", "OA", new { MemoID = "<#=MemoID#>"}, null).ToString()).Title("Reply").Filterable(false).Sortable(false); 
      colums.Bound(o => o.MemoID).ClientTemplate(Html.ActionLink("Acknowledge", "PreviewMemo", "OA", new { id = "<#=MemoID#>"}, null).ToString()).Title("Acknowledge").Filterable(false).Sortable(false); 
      colums.Bound(o => o.Subject).ClientTemplate(Html.ActionLink("<%#=Subject#>", "PreviewMemo", "OA", new { id = "<#=MemoID#>" }, null).ToString()).Title("Subject"); 
      //colums.Bound(o => Html.ActionLink(o.Subject,"PreviewMemo","OA",new{id=o.MemoID},null).ToString()).Title("Subject"); 
      colums.Bound(o => o.FromEmployeeName); 
      colums.Bound(o => o.MemoDate); 
      }) 
    .Sortable() 
    .Filterable() 
    .RowAction((row) => 
    {    
      row.HtmlAttributes.Add("style", "background:#321211;"); 
    }) 
    .Pageable(pager=>pager.PageSize(6)) 
    .PrefixUrlParameters(false) 

     //.ClientEvents(events => events.OnRowDataBound("onRowDataBound")) 
     .Render();   
    %> 

我在哪裏結合第三列(主題)我的本意是讓一個ActionLink的其中subject是顯示文本,我想要一個來自<#=MemoID#>的動態ID。備忘錄ID工作正常,並給我一個與動態備忘錄ID的鏈接。 ("<#=Subject#>")的問題是在屏幕上呈現,因爲它沒有映射到備忘錄的實際主題。我也試過("<%#=Subject%>"),但沒有收穫。任何幫助,高度讚賞

問候

回答

12

有點晚了,現在也許你,但也許這將幫助別人:

我通過模板做到這一點,如下所示:

columns.Bound(c => c.ID).ClientTemplate(

      Html.ActionLink("<#= SomeTextValue #>", "SomeAction", "SomeController", new { ID = "<#= ID #>" }, null).ToString() 

    ).Title(""); 
1

我知道這是相當晚的,但我有一個非常類似的問題,我終於想通了,這個鏈接出現在搜索結果。
我正試圖添加一個Ajax.Actionlink到MVC網格的客戶端模板。最後發現問題來自UpdateTargetID =「myElement」。 Ajax.ActionLink爲更新目標生成非轉義的「#」。
我的工作是圍繞:

columns.Bound(p => p.ID).Title("myTitle") 
          .ClientTemplate(Ajax.ActionLink("View", "myAction", "myController", new { myParam = "#=ID#" }, new AjaxOptions() { OnSuccess = "myJSFunction" }).ToHtmlString()); 


然後:

function myJSFunction(response) { 
    $("#updateTargetElement").html(response); 
}