我正在使用一个 kendogrid 填充一些具有日期字段的数据。当它绑定到 kendogrid 时,我需要限制数据源中的日期。一个例子如下所示。在这里,我需要在 BirthDate 字段中禁用 1910 年 1 月 25 日之前的所有日期(例如)。
var data = createRandomData(50);
var autoCompleteDS = new kendo.data.DataSource({
data: [
{firstName: "Alex"},
{firstName: "Alice"},
{firstName: "Antony"},
{firstName: "Anne"},
{firstName: "Anna"}
]
});
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
data: data,
schema: {
model: {
fields: {
FirstName: { type: "string" },
LastName: { type: "string" },
City: { type: "string" },
Title: { type: "string" },
BirthDate: { type: "date" },
Age: { type: "number" }
}
}
},
pageSize: 10
},
height: 450,
scrollable: true,
sortable: true,
pageable: true,
editable: true,
edit: function(e) {
$(e.container)
.find("input[name='FirstName']")
.data("kendoAutoComplete")
.bind("change", function(e) {
console.log("auto complete changed");
});
},
toolbar: ["create"],
columns: [
{
field: "FirstName",
title: "First Name",
// width: 100
},
{
field: "BirthDate",
title: "Birth Date",
template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'
},
{
field: "Age",
width: 100
},
]
});
});
<link href="http://cdn.kendostatic.com/2012.2.710/styles/kendo.default.min.css" rel="stylesheet"/>
<link href="http://cdn.kendostatic.com/2012.2.710/styles/kendo.common.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2012.2.710/js/kendo.all.min.js"></script><script src="http://demos.telerik.com/kendo-ui/content/shared/js/people.js"></script>
<!-- grid element -->
<div id="grid" style="width: 700px; margin: 0 auto;"></div>