Question

I'm using Telerik grid to present memos received by user below is the code

<%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();          
  %> 

where I am binding third column (Subject) my intention is to make an ActionLink where subject is the display text and i want a dynamic ID coming from <#=MemoID#>. memo id is working fine and gives me a link with dynamic Memo IDs. the problem is with the subject i.e ("<#=Subject#>") is rendered as it is on the screen without mapping to the actual subject of the memo. I have also tried ("<%#=Subject%>") but to no gain. any help is highly appreciated

Regards

Was it helpful?

Solution

Bit late now maybe for you, but maybe this will help others:

I do this via templates, as follows:

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

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

      ).Title("");

OTHER TIPS

I realize this is pretty late but I had a very similar problem that I finally figured out and this link came up during search results.
I was trying to add an Ajax.Actionlink to a client template for MVC grid. Finally found the issue to stem from the UpdateTargetID = "myElement". Ajax.ActionLink generates an unescaped "#" for the update target.
My work around was:

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


Then:

function myJSFunction(response) {
    $("#updateTargetElement").html(response);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top