我正在使用一个kendo网格,其中一列由kendodatetimepicker
组成。
用户只能在昨天和今天编辑日期和时间。
因此,当他点击网格上的修改按钮时,datetimepicker
应首先显示默认的当前日期和时间
我的网格看起来像这样 -
columns: [
{ field: "EntryType", title: "Entry Type", width: "50px", editor: $scope.typeDropDownEditor, template: "#=EntryType#" },
{ field: "Chemical", title: "Chemical Name", width: "50px", editor: $scope.chemicalDropDownEditor,template: "#=Chemical.ChemicalName#" },
{ field: "Facility", title: "Facility Name", width: "50px", editor: $scope.facilityDropDownEditor, template: "#=(Facility.FacilityName==null)? '' : Facility.FacilityName #" },
{ field: "RecordedDate", title: "Date - Time", format: 'yyyy-mm-dd HH:mm:ss', editor: dateTimeEditor, width: "50px" },
{ field: "Remarks",title:"Remarks",width:"60px"},
{ field: "Volume", title: "Volume", width: "50px" },
{
command: [
{
name: "edit", title: "Edit", "template": "<a class='k-button k-grid-edit' href='' style='min-width:40px;' title=\"Edit\"><span class='k-icon k-i-edit'></span></a>"
},
], field: "Actions",title:"Actions", width: "50px"
}],
editable: "inline",
datetimepicker
编辑 -
function dateTimeEditor(container, options) {
$('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>')
.appendTo(container)
.kendoDateTimePicker({
value: $scope.tdate,
dateInput: true,
max: new Date(),
min: $scope.ydate,
//template: "#= kendo.toString(kendo.parseDate(value), 'yyyy-mm-dd HH:mm:ss') #"
});
}
tdate和ydate定义为 -
var today = new Date();
var yday = today.getDate() - 1;
var tday = today.getDate();
var month = today.getMonth();
var year = today.getFullYear();
var hour = today.getHours();
var minute = today.getMinutes();
var seconds = today.getSeconds();
$scope.ydate = (new Date(year, month, yday, hour, minute, seconds));
$scope.tdate = (new Date(year, month, tday, hour, minute, seconds));
将当前日期放在值字段中未提供所需的输出
答案 0 :(得分:0)
你可以尝试这个: StartDate是kendoDatePicker的id,您要在其中显示默认日期:
HTML:
<input id="datepickerjQuery">
var todayDate = kendo.toString(kendo.parseDate(new Date()), 'MM/dd/yyyy');
$("#datepickerjQuery").data("kendoDatePicker").value(todayDate);