This is a migrated thread and some comments may be shown as answers.

MVC Grid ClientTemplate - Invalid Template Error

1 Answer 788 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 2
IT asked on 13 Jul 2012, 02:18 PM
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;'

1 Answer, 1 is accepted

Sort by
0
loi
Top achievements
Rank 1
answered on 17 Jul 2012, 12:06 AM
old client template code block:  <#=  #>, <# #>
kendo template code block:  #=  #, # #

http://demos.kendoui.com/web/templates/expressions.html
Tags
Grid
Asked by
IT
Top achievements
Rank 2
Answers by
loi
Top achievements
Rank 1
Share this question
or