我正在使用Telerik网格来呈现下面用户收到的备忘录是代码
<%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%>"
),但没有收获。任何帮助都非常感谢
此致
答案 0 :(得分:12)
现在可能已经迟到了,但也许这会对其他人有所帮助:
我通过模板执行此操作,如下所示:
columns.Bound(c => c.ID).ClientTemplate(
Html.ActionLink("<#= SomeTextValue #>", "SomeAction", "SomeController", new { ID = "<#= ID #>" }, null).ToString()
).Title("");
答案 1 :(得分:1)
我意识到这已经很晚了,但我遇到了一个非常类似的问题,我终于弄明白了,这个链接在搜索结果中出现了。
我试图将 Ajax.Actionlink 添加到MVC网格的客户端模板中。最后发现问题源于UpdateTargetID =“myElement”。
Ajax.ActionLink 为更新目标生成未转义的“#”。
我的工作是:
CREATE TABLE esth_countries (
country_id varchar(2) COLLATE utf8_unicode_ci NOT NULL,
name varchar(100) COLLATE utf8_unicode_ci NOT NULL,
region varchar(40) COLLATE utf8_unicode_ci NOT NULL,
language_id varchar(2) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (country_id,language_id),
KEY language_id (language_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
的然后:强>
columns.Bound(p => p.ID).Title("myTitle")
.ClientTemplate(Ajax.ActionLink("View", "myAction", "myController", new { myParam = "#=ID#" }, new AjaxOptions() { OnSuccess = "myJSFunction" }).ToHtmlString());