Using MVC4, trying to load a partial view using a ClientTemplate in the grid and a Kendo Window. I'm getting an Invalid Template error. Any help is appreciated. Thanks!
Grid:
@(Html.Kendo()
.Grid<
TestKendoGrid.Models.myTransactions
>()
.Name("Grid")
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Columns(columns =>
{
columns.Bound(o => o.TranDt).Width(150);
columns.Bound(o => o.Description).Width(300);
columns.Bound(o => o.Category).Width(125);
columns.Bound(o => o.Amount).Width(100).Format("{0:c}");
columns.Bound(o => o.TranID)
.ClientTemplate(
Ajax.ActionLink("Details",
"ShowDetails",
"Home",
new { id = "<#=TranID#>" },
new AjaxOptions
{
UpdateTargetId = "TranDetails",
InsertionMode = InsertionMode.Replace,
OnSuccess = "ShowWindow",
HttpMethod = "POST"
},
new { name = "Details<#=TranID#>" }
).ToString()
);
columns.Command(command => command.Destroy());
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.TranID))
.Events(events => { events.Error("error_handler"); })
.Create(create => create.Action("_CreateTransactionKendo", "Home"))
.Read(read => read.Action("_SelectTransactionsKendo", "Home"))
.Update(update => update.Action("_SaveTransactionKendo", "Home"))
.Destroy(destroy => destroy.Action("_DeleteTransactionKendo", "Home"))
.Batch(true))
Kendo Window:
@{ Html.Kendo().Window()
.Name("DetailWindow")
.Title("Transaction")
.Events(events => events.Close("RefreshGrid"))
.Content(@<
text
>
<
div
id
=
"TranDetails"
>
</
div
>
</
text
>)
.Width(425).Height(310).Visible(false).Render();
}
Scripts:
<
script
>
function ShowWindow() {
$("#DetailWindow").data('kendoWindow').center().open();
}
</
script
>
Controller:
[HttpPost]
public PartialViewResult ShowDetails(int id)
{
List<
myTransactions
> list = (List<
myTransactions
>)TempData["Trans"];
var target = list.Find(p => p.TranID == id.ToString());
return PartialView("_TransDetail", target);
}
Error:
Microsoft JScript runtime error: Invalid template:'<
tr
data-uid
=
"#=uid#"
><
td
>${TranDt}</
td
><
td
>${Description}</
td
><
td
>${Category}</
td
><
td
>${kendo.format("{0:c\}",Amount)}</
td
><
td
><
a
data-ajax
=
"true"
data-ajax-method
=
"POST"
data-ajax-mode
=
"replace"
data-ajax-success
=
"ShowWindow"
data-ajax-update
=
"#TranDetails"
href
=
"/Home/ShowDetails/%3C%23%3dTranID%23%3E"
name="Details<#=TranID#>">Details</
a
></
td
><
td
><
a
class
=
"k-button k-button-icontext k-grid-delete"
href
=
"\#"
><
span
class
=
"k-icon k-delete"
></
span
>Delete</
a
></
td
></
tr
>' Generated code:'var o,e=kendo.htmlEncode;with(data){o='<
tr
data-uid
=
"'+(uid)+'"
><
td
>'+(e(TranDt))+'</
td
><
td
>'+(e(Description))+'</
td
><
td
>'+(e(Category))+'</
td
><
td
>'+(e(kendo.format("{0:c}",Amount)))+'</
td
><
td
><
a
data-ajax
=
"true"
data-ajax-method
=
"POST"
data-ajax-mode
=
"replace"
data-ajax-success
=
"ShowWindow"
data-ajax-update
=
"';TranDetails"
href
=
"/Home/ShowDetails/%3C%23%3dTranID%23%3E"
name="Details<;o+='=TranID';>">Details</
a
></
td
><
td
><
a
class
=
"k-button k-button-icontext k-grid-delete"
href
=
"#"
><
span
class
=
"k-icon k-delete"
></
span
>Delete</
a
></
td
></
tr
>;o+=;}return o;'