【发布时间】:2017-02-24 13:35:19
【问题描述】:
我的数据源中有一个可为空的 DateTime 属性 - ExpectedReceiptDate,我正在网格中实现内联编辑:
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
transport: {
//setup transport
},
schema:
{
data: 'Data', total: 'Total', errors: 'Errors',
model:
{
id: 'Id',
fields: {
Id : { editable: false, type: 'number' },
Name : { editable: false, type: 'string' },
ExpectedReceiptDate : {
editable: true,
format: "{0: dd/MMM/yyyy}",
nullable: true,
type: 'date'
}
}
}
},
requestEnd: function(e) {
if (e.type == 'update') {this.read();}
},
serverFiltering: true,
serverSorting: true
},
editable: {
mode: "inline"
},
columns: [
{
field: "Id",
title: "ID"
},{
field: "Name",
title: "Name"
},{
field: "ExpectedReceiptDate",
title: "Date",
editor: DateEditor,
},
{
title: " ",
command: ["edit"],
width: 200
}
]
});
});
编辑器很简单:
function DateEditor(container, options) {
$('<input required name="' + options.field + '"/>')
.appendTo(container)
.kendoDatePicker({format: "dd/MMM/yyyy"});
}
在编辑获取日期的行时,例如 24/Feb/2017 我收到一个错误:
无效的模型状态 ExpectedReceiptDate,值“(日期)FLE 标准时间”对于 ExpectedReceiptDate 无效
我已尝试为该字段添加自定义验证:
function ExpectedReceiptDateValidator(input){
if (input.is("[name='ExpectedReceiptDate']") && input.val() != "") {
try {
var date = kendo.parseDate(input.val(), "dd/MMM/yyyy");
if(!date)
return false;
} catch (err) { return false;}
console.log('res', true);
}
return true;
}
验证通过,输入的日期值被很好地解析为Date obj,但模型状态错误仍然存在。 是什么导致模型状态错误?
【问题讨论】:
标签: kendo-ui kendo-grid kendo-datepicker