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

Uncaught Error: Invalid template

5 Answers 558 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 28 Jul 2014, 03:56 PM
Hi,

Last week, we have performed Kendo UI upgrade but after that we encountered some errors but manage to made some code adjustments.

Now my main concern is that before the update the below grid is working as you see on the image below (or screenshot 0002.png)



I am doing some test on my existing codes as shown below but it is really weird that after the update I am getting the above error.

This is the code said code.

@{
    ViewBag.Controller = "POs";
    ViewBag.TemplateController = "POLines";
    ViewBag.Area = "KOKO";
}
@(Html.Kendo().Grid<PO>()
    .Name("PurchaseOrderList")
    .HtmlAttributes(new { @class = "grid nowrap" })
    .ToolBar(commands =>
    {
        commands.Create()
            .Text(Html.ButtonsResource("AddPurchaseOrder"))
            .HtmlAttributes(new { @class = "t-add" });
 
    })
    .Columns(columns =>
    {
        columns
            .Bound(x => x.OriginPortId)
            .Hidden();
        columns
            .Bound(x => x.PONumber)
            .Title(Html.PropertiesResource("PO.PONumber"));
        columns
            .Bound(x => x.OriginPortName)
            .EditorViewData(new { Action = "GetFilteredPortByVendorOrFactory", Controller = "DataSource", onData = "onInlinePortOfOrigin", onSelect = "onInlinePortSelectById" })
            .EditorTemplateName("InlineAutoComplete")
            .Title(Html.PropertiesResource("PO.OriginPortId"));
        columns
            .Bound(x => x.TotalPOQuantity)
            .Title(Html.PropertiesResource("PO.TotalPOQuantity"));
        columns
            .Bound(x => x.TotalASNQuantity)
            .Title(Html.PropertiesResource("PO.TotalASNQuantity"));
        columns
            .Bound(x => x.TotalGRNQuantity)
            .Title(Html.PropertiesResource("PO.TotalGRNQuantity"));
        columns
            .Bound(x => x.Variance)
            .Title(Html.PropertiesResource("PO.Variance"));
        columns.Command(commands =>
            {
                commands
                    .Edit()
                    .HtmlAttributes((new { title = Html.ButtonsResource("Edit") }));
                commands
                    .Destroy()
                    .HtmlAttributes((new { title = Html.ButtonsResource("Delete") }));
            }
           )
           .Width("5%")
           .HtmlAttributes(new { @class = "nowrap" })
           .Title(Html.StringsResource("Commands"));
    })
    .PrefixUrlParameters(false)
    .ClientDetailTemplateId("asnPurchaseOrderLineTemplate")
    .EnableCustomBinding(true)
    .Sortable(x => x.SortMode(GridSortMode.SingleColumn))
    .Filterable()
    .Events(events => events
        .Save("SaveASNPurchaseOrder")
        .DataBound("KendoGrid.DataBound")
        .Edit("KendoGrid.Edit"))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model
                .Id(x => x.Id);
            model
                .Field(x => x.TotalPOQuantity)
                .Editable(false);
            model
                .Field(x => x.TotalASNQuantity)
                .Editable(false);
            model
                .Field(x => x.TotalGRNQuantity)
                .Editable(false);
            model
                .Field(x => x.Variance)
                .Editable(false);
        })
        .Events(e => e
            .Error("KendoGrid.Error")
            .RequestEnd("KendoGrid.RequestEnd"))
        .Create(create => create.Action("Add", (String)ViewBag.Controller, new { area = (String)(ViewBag.Area ?? String.Empty) }))
        .Read(read => read.Action("Index", (String)ViewBag.Controller, new { area = (String)(ViewBag.Area ?? String.Empty), ASNId = Request[Constants.ASNId] }))
        .Update(create => create.Action("Update", (String)ViewBag.Controller, new { area = (String)(ViewBag.Area ?? String.Empty) }))
        .Destroy(create => create.Action("Remove", (String)ViewBag.Controller, new { area = (String)(ViewBag.Area ?? String.Empty) }))
        .PageSize(((DataSourceRequest)ViewData[Constants.Request]).PageSize)
    )
    .Pageable(pager => pager
        .Input(true)
        .Refresh(true)
    )
)
<script>
    function SaveASNPurchaseOrder(e) {
        e.model.UrlMask = GetUrlMask();
        e.model.ASNId = '@ViewContext.RouteData.Values[Constants.ASNId]';
    }
</script>
<script id="asnPurchaseOrderLineTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<POLines>()
    .Name("productLines_#=Id#")
    .HtmlAttributes(new { @class = "grid nowrap" })
    .ToolBar(commands =>
    {
        commands.Create()
            .Text(Html.ButtonsResource("AddItem"))
            .HtmlAttributes(new { @class = "t-add" });
 
    })
    .Columns(columns =>
    {
        columns
            .Bound(x => x.ProductMasterGTINId)
            .Hidden();
        columns
            .Bound(x => x.Code)
            .EditorViewData(new { Action = "GetCompleteProduct", Controller = "DataSource", onSelect = "onProductDetailSelectById", onData = "onProductDataById" })
            .EditorTemplateName("InlineAutoCompleteProductAndGTIN")
            .Width(300);
        columns
            .Bound(x => x.Description)
            .EditorTemplateName("InlineString")
            .EditorViewData(new { disabled = "disabled" })
            .Title(Html.PropertiesResource("POLines.Description"));
        columns
            .Bound(x => x.HTSCode)
            .EditorTemplateName("InlineString")
            .EditorViewData(new { disabled = "disabled" })
            .Title(Html.PropertiesResource("POLines.HTSCode"));
        columns
            .Bound(x => x.GTIN)
            .EditorTemplateName("InlineString")
            .EditorViewData(new { disabled = "disabled" })
            .Title(Html.PropertiesResource("POLines.GTIN"));
        columns
            .Bound(x => x.SKU)
            .EditorTemplateName("InlineString")
            .EditorViewData(new { disabled = "disabled" })
            .Title(Html.PropertiesResource("POLines.SKU"));
        columns
            .Bound(x => x.Attributes)
            .EditorTemplateName("InlineString")
            .EditorViewData(new { disabled = "disabled" })
            .ClientTemplate("\\#= Attributes \\#")
            .Title(Html.PropertiesResource("ProductMasterGTINViewModel.AttributeString"));
        columns
            .Bound(x => x.POQuantity)
            .Title(Html.PropertiesResource("POLines.POQuantity"));
        columns
            .Bound(x => x.ASNQuantity)
            .Title(Html.PropertiesResource("POLines.ASNQuantity"));
        columns
            .Bound(x => x.GRNQuantity)
            .Title(Html.PropertiesResource("POLines.GRNQuantity"));
        columns
            .Bound(x => x.Variance)
            .Title(Html.PropertiesResource("POLines.Variance"));
        columns.Command(commands =>
            {
                commands
                    .Edit()
                    .HtmlAttributes((new { title = Html.ButtonsResource("Edit") }));
                commands
                    .Destroy()
                    .HtmlAttributes((new { title = Html.ButtonsResource("Delete") }));
            }
            )
            .Width("5%")
            .HtmlAttributes(new { @class = "nowrap" })
            .Title(Html.StringsResource("Commands"));
    })
    .PrefixUrlParameters(false)
    .Events(events => events
        .Save("SavePurchaseOrderProductLine")
        .DataBound("KendoGrid.DataBound")
        .Edit("KendoGrid.Edit"))
    .Sortable(x => x.SortMode(GridSortMode.SingleColumn))
    .Editable(x => x.Mode(GridEditMode.InLine))
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
            {
                model.Id(x => x.Id);
                model.Field(x => x.GRNQuantity).Editable(false);
                model.Field(x => x.Variance).Editable(false);
 
            })
        .Events(e => e
            .Error("KendoGrid.Error")
            .RequestEnd("KendoGrid.RequestEnd"))
        .Create(create => create.Action("Add", (String)ViewBag.TemplateController, new { area = (String)(ViewBag.Area ?? String.Empty), PurchaseOrderId = "#=Id#" }))
        .Read(read => read.Action("Index", (String)ViewBag.TemplateController, new { area = (String)(ViewBag.Area ?? String.Empty), PurchaseOrderId = "#=Id#" }))
        .Update(create => create.Action("Update", (String)ViewBag.TemplateController, new { area = (String)(ViewBag.Area ?? String.Empty) }))
        .Destroy(create => create.Action("Remove", (String)ViewBag.TemplateController, new { area = (String)(ViewBag.Area ?? String.Empty) }))
        .PageSize(((DataSourceRequest)ViewData[Constants.Request]).PageSize)
    )
    .Pageable(pager => pager
    .Input(true)
    .Refresh(true)
    )
    .ToClientTemplate()
    )
</script>
 
<script>
    function SavePurchaseOrderProductLine(e) {
        e.model.UrlMask = GetUrlMask();
    }
</script>

When I tried to partially try to figure out the issue this line is cause the problem as it seemed that the code cannot find the said templateId.

.ClientDetailTemplateId("asnPurchaseOrderLineTemplate")

But when I commented the above code it shows the grid (see attached Screenshots 0001.png).



As far as our Foundation Server is concern we didn't see any changes on the said file but now we encountered this after the update.

I hope you can advise us on this as we will be doing system release pretty soon.

Thanks,


Rhan Tepe Takamiya
on Behalf of Steve


5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 30 Jul 2014, 08:01 AM
Hi Steve,

I'm afraid that I'm unable to observe such error locally. I have attached a test application which uses the pasted code snippet. Please take a look maybe I'm missing something obvious. Feel free to modify it as the issue to appear and send it back to us for further investigation.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Steve
Top achievements
Rank 1
answered on 30 Jul 2014, 10:03 AM
Hi Rosen,

Thanks for the above response.

Now I figure out what causing the error because it will never be obvious on the above codes but now here is the issue.

I have dissected the said template by showing the columns one by one until the error occur now I pointed out that those editable number fields is now causing the error.

This is the model for the template grid:

public class POLine
{
    public long ASNPurchaseOrderId { get; set; }
    public long ProductMasterGTINId { get; set; }
    public String Code { get; set; }
    public String Description { get; set; }
    public String HTSCode { get; set; }
    public String GTIN { get; set; }
    public String SKU { get; set; }
    public String Attributes { get; set; }
    public long? POQuantity { get; set; }
    public long? ASNQuantity { get; set; }
    public long GRNQuantity { get; set; }
    public long? Variance { get { return GRNQuantity - ASNQuantity; } }
}


Now here's the catch, when I use integer data type the field is not causing any error but when I am using a long data type now the error occur however all of our record identifiers are configured to use long as we are using specific number sequence that integer cannot cater.

This was never an issue before but now it became.

I hope you can help us with this.

Thanks,



Rei Banaag
Developer

0
Rosen
Telerik team
answered on 30 Jul 2014, 11:41 AM
Hello Rei,

I'm still unable to observe the issue in question. Therefore, please modify the test project I have attached to my previous reply and send it back to us.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Steve
Top achievements
Rank 1
answered on 06 Aug 2014, 08:50 AM
Hi Rosen,

I think we aren't going any further on this we just revert the old version of Kendo.

We cannot share our codes that is causing the issue but definitely the upgrade is causing it.

Thanks,




Rei
0
Nikolay Rusev
Telerik team
answered on 07 Aug 2014, 03:08 PM
Hello Steve,

Indeed we are not able to replicate this problem in the project of my colleague Rosen even when changing the type of the fields to long.

However as you say that the issue is only reproducible with long type but not with int, is there a chance that you are using special editor template for long types that is making the difference. Can you please check the EditorTemplates defined?

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Steve
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or