我有一个剑道网格,其中一列应该是 0 到 12 之间的数字。除 HourTimeHours 外,其他一切都工作正常。我不能将最小值设置为小于 0,但我可以将其设置为大于 12。请帮忙。
schema: {
model: {
id: "ID",
fields: {
ID: { editable: false },
TName: { editable: false },
HourTimeHours: { editable: true, type: "number", validation: { required: true, min: 0, max: 12 } },
Comment: { editable: true, nullable: true },
Reason: { editable: false, nullable: true },
ChargeRateText: { defaultValue: { CategoryID: "No Charge", CategoryName: "No Charge" } },
}
},
最佳答案
您必须在创建网格时为该字段指定一个编辑器。
$("#grid").kendoGrid({
dataSource: dataSource,
columns: [
{ field: "HourTimeHours", title: "Hours", editor: hoursDropDownEditor }],
editable: true
});
然后,如果您想要剑道数字文本框之类的东西,您的函数将如下所示:
function hoursDropDownEditor(container, options) {
$('<input/>')
.appendTo(container)
.kendoNumericTextBox({
min: 1,
max: 12,
step: 1
});
}
更新:您还可以使用模板,让用户清楚地知道该字段是可编辑的。
关于kendo-ui - 如何在 Kendo Grid 内联编辑中将数字输入限制在 1 到 12 之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19514934/