我有一个需要选择日期和日期的要求,以便日期应该在网格中匹配并显示结果。但是带有日期的网格列包含日期+时间。所以我的问题是可以忽略时间并只读日期在往返日期选择器中并匹配网格中的值。
$("#datepicker").kendoDatePicker({
dateFormat: "dd-mm-yy",
format : "dd-MM-yy "});
$("#datepicker1").kendoDatePicker({
dateFormat: "dd-mm-yy",
format : "dd-MM-yy "});
var result=$("#grid").kendoGrid({
filterable: true,
columns: [
{ field: "FirstName", title: "First Name" },
{ field: "LastName", title: "Last Name" },
{ field: "dob", title: "DOB" , format: "{0:dd-MM-yy HH:mm:ss}"}
],
dataSource: {
data: [
{ FirstName: "Joe", LastName: "Smith" ,dob:"2013-02-18 19:54:13"},
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-02-18 20:55:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-05-30 21:56:15" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-05-18 22:57:16" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-02-19 20:55:20" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-02-24 20:56:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-03-26 20:57:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-02-28 20:42:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-03-22 11:55:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-03-27 20:55:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-04-18 20:55:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-04-23 20:55:14" },
{ FirstName: "Jane", LastName: "Smith" ,dob:"2013-04-24 20:55:14" }
],
schema: {
data: function (data) {
$.each(data, function (i, val) {
val.dob = kendo.parseDate(val.dob, "yyyy-MM-dd HH:mm:ss");
});
return data;
}
}
}
}).data("kendoGrid");
$("#datepicker, #datepicker1").on("change", function (){
var mindate = $('#datepicker').data("kendoDatePicker").value();
var maxdate = $('#datepicker1').data("kendoDatePicker").value();
var condition = {
logic : "and",
filters: [
]
};
if (mindate !== null) {
condition.filters.push({ field: "dob", operator: "ge", value: mindate });
}
if (maxdate !== null) {
condition.filters.push({ field: "dob", operator: "le", value: maxdate });
}
result.dataSource.filter(condition);
});