gpt4 book ai didi

javascript - KendoUI 网格过滤日期格式

转载 作者:数据小太阳 更新时间:2023-10-29 04:00:34 25 4
gpt4 key购买 nike

在我的剑道网格中,我想更改过滤器中的日期格式

Ex: 1/30/2015 to Jan 30, 2015

我已经更改了 Start Date 的日期格式

                field: "StartDate",
title: "Start Date",
width: 30,
format: "{0:MMM dd, yyyy}",
parseFormats: "{0:MM/dd/yyyy}",
headerTemplate: '<label for="check-all"><b>Start Date</b></label>',
headerAttributes: { style: "text-align: center;" },
attributes: { style: "text-align:center !important;padding-right: 25px;" }

我的可过滤代码

  filterable: {
extra: false,
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to"
}
}
},

截图 see this

谢谢

最佳答案

您应该将 filterable.ui 定义为创建 DatePicker 并设置所需的 format 的函数:

{
field: "StartDate",
title: "Start Date",
width: 30,
format: "{0:MMM dd, yyyy}",
parseFormats: "{0:MM/dd/yyyy}",
headerTemplate: '<label for="check-all"><b>Start Date</b></label>',
headerAttributes: { style: "text-align: center;" },
attributes: { style: "text-align:center !important;padding-right: 25px;" },
filterable : {
ui: function (element) {
element.kendoDatePicker({
format: "MMM dd, yyyy"
});
}
}
},

检查以下代码段:

$(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" },
Freight: { type: "number" },
ShipName: { type: "string" },
OrderDate: { type: "date" },
ShipCity: { type: "string" }
}
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
height: 550,
filterable: true,
sortable: true,
pageable: true,
columns: [
{
field:"OrderID",
filterable: false
},
{
field: "OrderDate",
title: "Order Date",
format: "{0:MMM dd, yyyy}",
parseFormats: "{0:MM/dd/yyyy}",
headerTemplate: '<label for="check-all"><b>Start Date</b></label>',
headerAttributes: { style: "text-align: center;" },
attributes: { style: "text-align:center !important;padding-right: 25px;" },
filterable : {
ui: function (element) {
element.kendoDatePicker({
format: "MMM dd, yyyy"
});
}
}
},
"ShipName"
]
});
});
html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1316/styles/kendo.common.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1316/styles/kendo.default.min.css" />
<script src="http://cdn.kendostatic.com/2014.3.1316/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1316/js/kendo.all.min.js"></script>

<div id="grid"></div>

关于javascript - KendoUI 网格过滤日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28232575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com