在我的MVc项目中有一些语言资源(.resx)文件。想要将字符串值传递给kendo模板。如果值有一些特殊字符,如'ç','ş'等...它会出错:
Html- Razor:
@(Html.Kendo().ListView<AIS.UI.WebService.Proxy.DSrvAllService.CaseListItemModel>()
.Name("listView")
.TagName("div")
.HtmlAttributes(new { style = "padding-left:15px" })
.ClientTemplateId("template")
.DataSource(dataSource => dataSource
.Model(model => model.Id("CASEID"))
.PageSize(5)
.Events(events => events.Error("onError"))
.Read(read => read.Action("GetListCases", "Case"))
)
.Pageable()
.Editable()
)
<script type="text/x-kendo-tmpl" id="template" >
<span>@CaseList.elapsed</span>
错误:
Uncaught Error: Invalid template:'
经过的值包含'ç'字符,因此收到错误。
答案 0 :(得分:2)
使用@ Html.Raw()修复了poblem.Like:
<span>@Html.Raw(@CaseList.elapsed)</span>
答案 1 :(得分:0)
您是否检查过您的浏览器接收的模板?尝试定义没有字段的模板(只有这个@CaseList.elapsed
)并查看它是否有效。
KendoUI模板支持ç
字符,如您所见:http://jsfiddle.net/OnaBai/XNcmt/43/
<div id="data"></div>
<script type="text/x-kendo-tmpl" id="template" >
<div>This is a literal: <span class="ob-literal">If value has some special characters like 'ç' , 'ş' etc... it gives an error</span></div>
<div>This is actually a variable bound to the template: <span class="ob-value">#= text #</span></div>
</script>
var template = kendo.template($("#template").html());
var data = { text: "If value has some special characters like 'ç' , 'ş' etc... it gives an error" };
$("#data").html(template(data));