Invalid Template

0 Answers 25 Views
Grid
Anh
Top achievements
Rank 1
Anh asked on 01 Apr 2022, 02:39 PM | edited on 01 Apr 2022, 02:43 PM

Hello,

I am pretty new to Kendo and am looking for some help.  Getting an invalid template error when data has #. Not sure which cshtml or cs file that I need to update to fix this. Any help is appreciated.  

kendo.all.js:238 Uncaught Error: Invalid template:'

    <div class="k-widget k-grid" id="grid_#=AggregateID#"><div class="k-header k-grid-toolbar k-grid-top"><a class="k-button k-button-icontext k-grid-add" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-mode=insert"><span class="k-icon k-i-add"></span>Add New Record</a></div><div class="k-grid-header"><div class="k-grid-header-wrap"><table><colgroup><col style="width:150px" /><col style="width:300px" /><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-index="0" id="1e37206d-9413-4245-8db3-97f8bc0e21a4" scope="col"><span class="k-link"> </span></th><th class="k-header" data-field="ItemAggregateID" data-index="1" data-title="Item Aggregate ID" id="#=kendo.guid()#" scope="col" style="display:none"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=ItemAggregateID-asc">Item Aggregate ID</a></th><th class="k-header" data-field="AggregateID" data-index="2" data-title="Aggregate ID" id="#=kendo.guid()#" scope="col" style="display:none"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=AggregateID-asc">Aggregate ID</a></th><th class="k-header" data-field="AggregateOptionID" data-index="3" data-title="Option Name" id="#=kendo.guid()#" scope="col"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=AggregateOptionID-asc">Option Name</a></th><th class="k-header" data-field="ItemID" data-index="4" data-title="Source" id="#=kendo.guid()#" scope="col"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=ItemID-asc">Source</a></th></tr></thead></table></div></div><div class="k-grid-content k-auto-scrollable" style="height:200px"><table><colgroup><col style="width:150px" /><col style="width:300px" /><col /></colgroup><tbody><tr class="k-no-data"><td colspan="3"></td></tr></tbody></table></div></div><script>
	kendo.syncReady(function(){jQuery("\#grid_#=AggregateID#").kendoGrid({"save":OptionMembershipSave,"columns":[{"width":"150px","command":[{"name":"edit","buttonType":"ImageAndText","text":{"cancel":" ","update":" ","edit":" "}},{"name":"destroy","buttonType":"ImageAndText","text":" "}]},{"title":"Item Aggregate ID","headerAttributes":{"data-field":"ItemAggregateID","data-title":"Item Aggregate ID","id":"#=kendo.guid()#"},"hidden":true,"field":"ItemAggregateID","encoded":true,"editor":"\u003cinput class=\"text-box single-line\" data-val=\"true\" data-val-number=\"The field ItemAggregateID must be a number.\" data-val-required=\"The ItemAggregateID field is required.\" id=\"ItemAggregateID\" name=\"ItemAggregateID\" type=\"number\" value=\"0\" /\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"ItemAggregateID\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Aggregate ID","headerAttributes":{"data-field":"AggregateID","data-title":"Aggregate ID","id":"#=kendo.guid()#"},"hidden":true,"field":"AggregateID","encoded":true,"editor":"\u003cinput data-val=\"true\" data-val-number=\"The field AggregateID must be a number.\" data-val-required=\"Please select aggregate name\" id=\"AggregateID\" name=\"AggregateID\" value=\"0\" /\u003e\u003cscript\u003e\tkendo.syncReady(function(){jQuery(\"\\#AggregateID\").kendoTextBox({\"value\":\"0\"});});\u003c\\/script\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"AggregateID\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e"},{"title":"Option Name","headerAttributes":{"data-field":"AggregateOptionID","data-title":"Option Name","id":"#=kendo.guid()#"},"width":"300px","field":"AggregateOptionID","encoded":true,"editor":"\u003cinput data-val=\"true\" data-val-number=\"The field AggregateOptionID must be a number.\" data-val-required=\"Please select option name\" id=\"AggregateOptionID\" name=\"AggregateOptionID\" type=\"text\" value=\"0\" /\u003e\u003cscript\u003e\tkendo.syncReady(function(){jQuery(\"\\#AggregateOptionID\").kendoDropDownList({\"dataSource\":[{\"Text\":\"Product Offering: International\",\"Value\":\"1029\"},{\"Text\":\"Product Offering: Premium Model\",\"Value\":\"1030\"},{\"Text\":\"Product Offering: Standard Model\",\"Value\":\"1031\"},{\"Text\":\"Region: Americas\",\"Value\":\"1026\"},{\"Text\":\"Region: Asia/Pacific\",\"Value\":\"1027\"},{\"Text\":\"Region: Europe\",\"Value\":\"1028\"}],\"dataTextField\":\"Text\",\"dataValueField\":\"Value\"});});\u003c\\/script\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"AggregateOptionID\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e","values":[{"text":"Product Offering: International","value":"1029"},{"text":"Product Offering: Premium Model","value":"1030"},{"text":"Product Offering: Standard Model","value":"1031"},{"text":"Region: Americas","value":"1026"},{"text":"Region: Asia/Pacific","value":"1027"},{"text":"Region: Europe","value":"1028"}]},{"title":"Source","headerAttributes":{"data-field":"ItemID","data-title":"Source","id":"#=kendo.guid()#"},"field":"ItemID","encoded":true,"editor":"\u003cinput data-val=\"true\" data-val-number=\"The field ItemID must be a number.\" data-val-required=\"Please select Subfamily\" id=\"ItemID\" name=\"ItemID\" type=\"text\" value=\"0\" /\u003e\u003cscript\u003e\tkendo.syncReady(function(){jQuery(\"\\#ItemID\").kendoDropDownList({\"dataSource\":[{\"Text\":\"Receivers / AM/FM Radio / Asia B Mod\",\"Value\":\"1041\"},{\"Text\":\"Receivers / AM/FM Radio / Asia Radios\",\"Value\":\"1002\"},{\"Text\":\"Receivers / AM/FM Radio / Specials\",\"Value\":\"1009\"},{\"Text\":\"Receivers / AM/FM Radio / US Compact\",\"Value\":\"1015\"},{\"Text\":\"Receivers / AM/FM Radio / US Radios\",\"Value\":\"1019\"},{\"Text\":\"Receivers / Cellular / Asia Radios\",\"Value\":\"1042\"},{\"Text\":\"Receivers / Industrial / R\\u0026D\",\"Value\":\"1006\"},{\"Text\":\"Receivers / Industrial / Specials\",\"Value\":\"1010\"},{\"Text\":\"Receivers / Industrial / Standards\",\"Value\":\"1011\"},{\"Text\":\"Receivers / Medical / Medical\",\"Value\":\"1005\"},{\"Text\":\"Two Way / Cellular / Europe C Mod\",\"Value\":\"1003\"},{\"Text\":\"Two Way / Cellular / R\\u0026D\",\"Value\":\"1007\"},{\"Text\":\"Two Way / Cellular / US A Mod\",\"Value\":\"1012\"},{\"Text\":\"Two Way / Cellular / US B Mod\",\"Value\":\"1013\"},{\"Text\":\"Two Way / Cellular / US C Mod\",\"Value\":\"1014\"},{\"Text\":\"Two Way / Industrial / Asia C Mod\",\"Value\":\"1001\"},{\"Text\":\"Two Way / LMR / Europe P Mod\",\"Value\":\"1004\"},{\"Text\":\"Two Way / LMR / R\\u0026D\",\"Value\":\"1008\"},{\"Text\":\"Two Way / LMR / US M Mod\",\"Value\":\"1016\"},{\"Text\":\"Two Way / LMR / US N Mod\",\"Value\":\"1017\"},{\"Text\":\"Two Way / LMR / US Other\",\"Value\":\"1018\"},{\"Text\":\"Two Way / Test# / Test #9\",\"Value\":\"398896\"}],\"dataTextField\":\"Text\",\"dataValueField\":\"Value\"});});\u003c\\/script\u003e\u003cspan class=\"field-validation-valid\" data-valmsg-for=\"ItemID\" data-valmsg-replace=\"true\"\u003e\u003c/span\u003e","values":[{"text":"Receivers / AM/FM Radio / Asia B Mod","value":"1041"},{"text":"Receivers / AM/FM Radio / Asia Radios","value":"1002"},{"text":"Receivers / AM/FM Radio / Specials","value":"1009"},{"text":"Receivers / AM/FM Radio / US Compact","value":"1015"},{"text":"Receivers / AM/FM Radio / US Radios","value":"1019"},{"text":"Receivers / Cellular / Asia Radios","value":"1042"},{"text":"Receivers / Industrial / R\u0026D","value":"1006"},{"text":"Receivers / Industrial / Specials","value":"1010"},{"text":"Receivers / Industrial / Standards","value":"1011"},{"text":"Receivers / Medical / Medical","value":"1005"},{"text":"Two Way / Cellular / Europe C Mod","value":"1003"},{"text":"Two Way / Cellular / R\u0026D","value":"1007"},{"text":"Two Way / Cellular / US A Mod","value":"1012"},{"text":"Two Way / Cellular / US B Mod","value":"1013"},{"text":"Two Way / Cellular / US C Mod","value":"1014"},{"text":"Two Way / Industrial / Asia C Mod","value":"1001"},{"text":"Two Way / LMR / Europe P Mod","value":"1004"},{"text":"Two Way / LMR / R\u0026D","value":"1008"},{"text":"Two Way / LMR / US M Mod","value":"1016"},{"text":"Two Way / LMR / US N Mod","value":"1017"},{"text":"Two Way / LMR / US Other","value":"1018"},{"text":"Two Way / Test# / Test #9","value":"398896"}]}],"sortable":true,"resizable":true,"scrollable":{"height":"200px"},"editable":{"confirmation":"Are you sure you want to delete this record?","confirmDelete":"Delete","cancelDelete":"Cancel","mode":"inline","create":true,"update":true,"destroy":true},"toolbar":{"command":[{"name":null,"buttonType":"ImageAndText","text":"Add New Record"}]},"noRecords":true,"messages":{"noRecords":"No assignments to display"},"dataSource":{"type":(function(){if(kendo.data.transports['aspnetmvc-ajax']){return 'aspnetmvc-ajax';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":"/Settings/GetItemAggregateList2?aggregateId=#=AggregateID#\u0026companyId=1"},"prefix":"","update":{"url":"/Settings/UpdateOptionAssignment?aggregateId=%3D#AggregateID#\u0026companyId=1"},"create":{"url":"/Settings/CreateOptionAssignment?aggregateId=#=AggregateID#\u0026companyId=1"},"destroy":{"url":"/Settings/DeleteOptionAssignment?aggregateId=%3D#AggregateID#\u0026companyId=1"}},"error":onError,"sync":sync_handler,"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"id":"ItemAggregateID","fields":{"ItemAggregateID":{"type":"number"},"ItemID":{"type":"number"},"AggregateOptionID":{"type":"number"},"AggregateID":{"type":"number"},"CompanyID":{"type":"number"},"ItemCompanyID":{"type":"number","defaultValue":null},"IsConsolidation":{"type":"boolean"},"CreatedDt":{"type":"date","defaultValue":null},"ModifiedDt":{"type":"date","defaultValue":null},"CreatedID":{"type":"string"},"ModifiedID":{"type":"string"}}}}}});});
<\/script>

' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='\n\n    <div class="k-widget k-grid" id="grid_'+(AggregateID)+'"><div class="k-header k-grid-toolbar k-grid-top"><a class="k-button k-button-icontext k-grid-add" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-mode=insert"><span class="k-icon k-i-add"></span>Add New Record</a></div><div class="k-grid-header"><div class="k-grid-header-wrap"><table><colgroup><col style="width:150px" /><col style="width:300px" /><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-index="0" id="1e37206d-9413-4245-8db3-97f8bc0e21a4" scope="col"><span class="k-link"> </span></th><th class="k-header" data-field="ItemAggregateID" data-index="1" data-title="Item Aggregate ID" id="'+(kendo.guid())+'" scope="col" style="display:none"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=ItemAggregateID-asc">Item Aggregate ID</a></th><th class="k-header" data-field="AggregateID" data-index="2" data-title="Aggregate ID" id="'+(kendo.guid())+'" scope="col" style="display:none"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=AggregateID-asc">Aggregate ID</a></th><th class="k-header" data-field="AggregateOptionID" data-index="3" data-title="Option Name" id="'+(kendo.guid())+'" scope="col"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=AggregateOptionID-asc">Option Name</a></th><th class="k-header" data-field="ItemID" data-index="4" data-title="Source" id="'+(kendo.guid())+'" scope="col"><a class="k-link" href="/Settings/GetItemAggregateList2?aggregateId=%23%3DAggregateID%23&companyId=1&grid_%23%3DAggregateID%23-sort=ItemID-asc">Source</a></th></tr></thead></table></div></div><div class="k-grid-content k-auto-scrollable" style="height:200px"><table><colgroup><col style="width:150px" /><col style="width:300px" /><col /></colgroup><tbody><tr class="k-no-data"><td colspan="3"></td></tr></tbody></table></div></div><script>\n\tkendo.syncReady(function(){jQuery("#grid_'+(AggregateID)+'").kendoGrid({"save":OptionMembershipSave,"columns":[{"width":"150px","command":[{"name":"edit","buttonType":"ImageAndText","text":{"cancel":" ","update":" ","edit":" "}},{"name":"destroy","buttonType":"ImageAndText","text":" "}]},{"title":"Item Aggregate ID","headerAttributes":{"data-field":"ItemAggregateID","data-title":"Item Aggregate ID","id":"'+(kendo.guid())+'"},"hidden":true,"field":"ItemAggregateID","encoded":true,"editor":"\u003cinput class=\\\"text-box single-line\\\" data-val=\\\"true\\\" data-val-number=\\\"The field ItemAggregateID must be a number.\\\" data-val-required=\\\"The ItemAggregateID field is required.\\\" id=\\\"ItemAggregateID\\\" name=\\\"ItemAggregateID\\\" type=\\\"number\\\" value=\\\"0\\\" /\u003e\u003cspan class=\\\"field-validation-valid\\\" data-valmsg-for=\\\"ItemAggregateID\\\" data-valmsg-replace=\\\"true\\\"\u003e\u003c/span\u003e"},{"title":"Aggregate ID","headerAttributes":{"data-field":"AggregateID","data-title":"Aggregate ID","id":"'+(kendo.guid())+'"},"hidden":true,"field":"AggregateID","encoded":true,"editor":"\u003cinput data-val=\\\"true\\\" data-val-number=\\\"The field AggregateID must be a number.\\\" data-val-required=\\\"Please select aggregate name\\\" id=\\\"AggregateID\\\" name=\\\"AggregateID\\\" value=\\\"0\\\" /\u003e\u003cscript\u003e\tkendo.syncReady(function(){jQuery(\\\"\#AggregateID\\\").kendoTextBox({\\\"value\\\":\\\"0\\\"});});\u003c\\/script\u003e\u003cspan class=\\\"field-validation-valid\\\" data-valmsg-for=\\\"AggregateID\\\" data-valmsg-replace=\\\"true\\\"\u003e\u003c/span\u003e"},{"title":"Option Name","headerAttributes":{"data-field":"AggregateOptionID","data-title":"Option Name","id":"'+(kendo.guid())+'"},"width":"300px","field":"AggregateOptionID","encoded":true,"editor":"\u003cinput data-val=\\\"true\\\" data-val-number=\\\"The field AggregateOptionID must be a number.\\\" data-val-required=\\\"Please select option name\\\" id=\\\"AggregateOptionID\\\" name=\\\"AggregateOptionID\\\" type=\\\"text\\\" value=\\\"0\\\" /\u003e\u003cscript\u003e\tkendo.syncReady(function(){jQuery(\\\"\#AggregateOptionID\\\").kendoDropDownList({\\\"dataSource\\\":[{\\\"Text\\\":\\\"Product Offering: International\\\",\\\"Value\\\":\\\"1029\\\"},{\\\"Text\\\":\\\"Product Offering: Premium Model\\\",\\\"Value\\\":\\\"1030\\\"},{\\\"Text\\\":\\\"Product Offering: Standard Model\\\",\\\"Value\\\":\\\"1031\\\"},{\\\"Text\\\":\\\"Region: Americas\\\",\\\"Value\\\":\\\"1026\\\"},{\\\"Text\\\":\\\"Region: Asia/Pacific\\\",\\\"Value\\\":\\\"1027\\\"},{\\\"Text\\\":\\\"Region: Europe\\\",\\\"Value\\\":\\\"1028\\\"}],\\\"dataTextField\\\":\\\"Text\\\",\\\"dataValueField\\\":\\\"Value\\\"});});\u003c\\/    at Object.compile (kendo.all.js:238:31)
    at Object.i [as template] (jquery.min.js:2:88757)
    at <anonymous>:2:1332
    at Object.n [as syncReady] (kendo.aspnetmvc.js:900:42)
    at <anonymous>:2:8
    at b (jquery.min.js:2:866)
    at He (jquery.min.js:2:48373)
    at S.fn.init.append (jquery.min.js:2:49724)
    at S.fn.init.<anonymous> (jquery.min.js:2:50816)
    at $ (jquery.min.js:2:32425)

Nikolay
Telerik team
commented on 06 Apr 2022, 09:23 AM

Hi Anh,

In the general case, this error points out that there is an invalid syntax of a template used on the page. More about Kendo UI templates you can find at the link below:

However, I am not able to localize a template in the provided serialized Grid. Can you please share the grid declaration and any related code you have? This will allow me to investigate further. Also, feel free to replicate the problem in a Dojo demo.

Regards,

Nikolay

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Anh
Top achievements
Rank 1
Share this question
or