我正在尝试DateTime
在我的 Kendo ListView 模板中格式化我的对象,但建议的kendo.toString
方法似乎对我不起作用。
我已经删除了很多与我的问题无关的代码,以使其更易于理解。
我有一个Kendo DataSource
如下所示:
contactDataSource: new kendo.data.DataSource({
transport: {
read: {
url: "/baa/contact/getcontacts",
dataType: "json",
type: "GET"
}
},
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number", editable: false, nullable: true },
CompanyName: { type: "string" },
ContactName: { type: "string" },
ContactPhone: { type: "string" },
ContactEmail: { type: "string" },
ImageUrl: { type: "string" },
Website: { type: "string" },
RecentBaas: [
{
Name: { type: "string" },
StatusDisplay: { type: "string" },
Status: { type: "number" },
LastModDate: { type: "date" }
}
]
}
}
}
})
然后我的视图上有一个模板,如下所示:
<script type="text/x-kendo-templ" id="contactTemplate">
<div class="row">
<div class="col-md-12">
# for (var i = 0; i < RecentBaas.length; i++) { #
# if (RecentBaas[i].Status == 1) { #
<div class="alert alert-success" role="alert">
<p>#=kendo.toString(RecentBaas[i].LastModDate, "F")#</p>
</div>
# } #
# } #
</div>
</div>
</script>
加载此页面时,我的控制台中没有任何错误,但日期根本没有格式化。它仍然只是显示/Date(1461203814927)/
例如。
我已经阅读了关于如何使用该toString
函数来格式化DateTime
对象的 Kendo 文档,并且据我所知,我所做的一切都是正确的。但也许我仍然缺少一些东西?