您的位置:首页 > 产品设计 > UI/UE

Kendo UI:Grid中单元格日期格式化

2017-04-27 17:57 176 查看
摘自: http://blog.csdn.net/sun_jy2011/article/details/41546337
Kendo UI:Grid中怎么格式化时间类型数据?

解决方案

(1)使用format格式化

{
field: "updateTime",
title: "更新时间",
width: 200,
format: "{0: yyyy-MM-dd HH:mm:ss}"
}


(2)使用template实现

{
field: "updateTime",
title: "更新时间",
width: 200,
template : kendo.template($("#updatetime_template").html())
}

<script type="text/x-kendo-template" id="updatetime_template">
#= kendo.toString(updateTime, "yyyy-MM-dd HH:mm:ss") #
</script>


  

以上两种方法都可以实现。但存在一个问题,必须把数据类型设置为date类型

dataSource: {
pageSize: 20,
transport: {
read: {
contentType: "application/json",
dataType: "json",
type: "Post",
url: "URL"
}
},
schema: {
data: "rows",
total: "total",
model: {
id: "ID",
fields: {
updateTime: { type: "date" }
}
}
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: