gpt4 book ai didi

javascript - Kendo Grid 内联编辑日期时间

转载 作者:行者123 更新时间:2023-12-03 06:22:02 30 4
gpt4 key购买 nike

我的剑道网格自定义编辑器有问题。当我单击剑道网格上的编辑按钮时,我想使用 dateTimePicker 作为编辑器。但是当我尝试使用 dateTimePicker 自定义网格时,总是出现错误:

Uncaught TypeError: e.indexOf is not a function ---------- kendo.custom.min.js:1 

这是简单的源代码:

  var data = [
{"id":1, "dateTime": 1420947900000},
{"id":2, "dateTime": 1421034300000},
{"id":3, "dateTime": 1421036100000},
];
$("#grid").kendoGrid({
selectable: true,
editable: "inline",
columns: [
{
field: "dateTime",
title: "<center>Date Time</center>",
width: "200px",
format: "{0:MM/dd/yyyy hh:mm}",
template: "#= kendo.toString(new Date(parseInt(dateTime)), 'MM/dd/yyyy hh:mm') #",
editor: dateTimeEditor2
},
{ command: ["edit", "destroy"], title: "&nbsp;", width: "170px" }
],
dataSource: {
transport: {
read: function(e) {
e.success(data);
},
update: function(e) {
//my update Function
alert(e.dateTime);
},
autosync: true
},
schema: {
model: {
id: "id",
fields: {
dateTime: { type: "datetime" },
}
}
}
}
});
function dateTimeEditor2(container, options) {
$('<input data-text-field="' + options.field + '" data-value-field="' + options.field
+ '" data-bind="value:' + options.field + '" />')
.appendTo(container)
.kendoDateTimePicker({
format:"MM/dd/yyyy hh:mm",
value: new Date(options.model.dateTime)
});
}

或者你可以在这个link上查看。

我也已经在许多不同的来源上检查过它,例如:

  1. Reference 1
  2. Reference 2

最佳答案

您的“日期时间”字段是数字,但您使用“日期时间”类型作为网格选项。在编辑器功能中,在自定义输入上使用“data-bind”属性会阻止 kendoUI 代码,因为我认为它需要某种日期文本..

我更改了您的代码,将字段类型更新为数字并删除了输入属性。错误消失了。但是,您需要使用自定义事件来实现 DateTimePicker,以便在编辑器值更改时更新网格 dataItem 的数值。或者可能当我想在您的示例中单击“更新”按钮时,通过将日期时间值解析为整数并设置网格数据项..

http://dojo.telerik.com/ecICE

额外说明:我还会考虑操作我的数据源数组,将这些数值更改为 JS DateTime 值,然后再将其绑定(bind)到网格。这可能是更简单的解决方案。

--

关于javascript - Kendo Grid 内联编辑日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38821755/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com