我有一个Kendo UI网格。在那里我有两列包含datepicker。 我想在进行内联编辑时比较每行的这两列之间的日期。单击“更新”时,应启动验证。 我不想使用编辑器模板。 这是我想要实现的代码。
fields: {
BusinessAreaDivisionMappingId: { type: "number", editable: false, nullable: false },
BatoDivisionMappingStatus: { type: "number", nullable: false, validation: { required: true } },
BusinessAreaHierarchyId: { type: "number", editable: false },
BusinessAreaCode: { type: "string", editable: false },
DivisionCode: { type: "string", editable: false },
ReferenceValue: { type: "string", validation: { required: true } },
StartDate: {
type: "date",
required: true,
validation: {
required: true,
dateComparisonValidation: function (element) {
alert('hi');
debugger;
var columnIndex = 0;
var grid = $("#bAPLMappingGrid").data("kendoGrid");
for (columnIndex; columnIndex < grid.columns.length; columnIndex++) {
if (grid.columns[columnIndex].field == "EndDate") {
break;
}
}
var StartDate = $(element).data("kendoDatePicker").value();
var EndDate = (new Date($(element).closest("tr").find("td:eq(" + columnIndex + ")").text()));
element.attr("data-dateComparisonValidation-msg", "Start Date Cannot be more than End Date");
if (StartDate && EndDate)
return (StartDate <= EndDate);
return true;
}
}
},
EndDate: { type: "date" },
IsDeleted: { type: "boolean", editable: false, nullable: true }