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

摘自: 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" }
                        }
                    }
                }
            }

  

 

posted @ 2017-04-27 17:57  fanjf  阅读(1836)  评论(0编辑  收藏  举报