我和大家分享一下我的kendo的学习心得。如果不好的地方多多包含或者给我留言请看图
kendo里时间格式如图Oder Date列里的格式。但是我们想把时间转换成中国人习惯的格式。如Shipped Date列里的格式。
这个就要在设置列里加一个格式format: "{0:yyyy/MM/dd}"请记住开头的 格式都要加一个0:你要排在前面的日期字母。如月/日格式:format:"{0:MM/dd}",单独月:format:"{0:MM}"整个Grid显示效果代码:
<div id="grid"></div>
<script>
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read:
"http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type:
"number" },
ShipCountry: {
type: "string" },
ShipCity: { type:
"string" },
ShipName: { type:
"string" },
OrderDate: { type: "date"
},
ShippedDate: {type: "date" }
}
}
},
pageSize: 15
},
height: 430,
sortable: true,
reorderable: true,
resizable: true,
pageable: true,
columns: [
{
field: "OrderDate",
title:
"Order Date",
width: 110,
format: "{0:MM/dd/yyyy}"
},
{
field:
"ShipCountry",
title: "Ship Country",
width: 110
},
{
field:
"ShipCity",
title: "Ship City",
width: 110
},
{
field: "ShipName",
title: "Ship Name",
width: 200
},
{
field: "ShippedDate",
title: "Shipped Date",
format:
"{0:yyyy/MM/dd}"
},
{
field: "OrderID",
title: "ID",
width: 60
}
]
});
});
</script>
</div>
详细访问http://demos.telerik.com/kendo-ui/web/grid/column-reordering.html