2010-06-15 74 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); 
}