Kendo ui 在剑道网格内联编辑中,如何将数字输入限制在1到12之间

Kendo ui 在剑道网格内联编辑中,如何将数字输入限制在1到12之间,kendo-ui,kendo-grid,kendo-asp.net-mvc,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我有一个剑道网格,其中一列的数字应该在0到12之间。除小时外,其他一切都运转良好。我不能将最小值设置为小于0,但我可以将其设置为大于12。请帮忙 schema: { model: { id: "ID", fields: { ID: { editable: false }, TName: { editable: false },

我有一个剑道网格,其中一列的数字应该在0到12之间。除小时外,其他一切都运转良好。我不能将最小值设置为小于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
    });
}
函数hoursDropDownEditor(容器,选项){
$('')
.appendTo(容器)
.Kendonumeric文本框({
民:1,,
最高:12,
步骤:1
});
}
更新:您还可以使用模板,让用户清楚该字段是可编辑的


对于剑道UI MVC,您可以限制剑道网格内联编辑的长度

    $("body").delegate("#percentage", "keyup", function () { 
        $("#percentage").attr('maxlength', '5');
    });
其中#percentage是要编辑的单元格id

columns.Bound(p => p.percentage);
所有网格:

@(Html.Kendo().Grid<Internal.Models.ExchangeRateData>()
    .Name("ExchangeGrid") 
    .Columns(columns =>
    { 
        columns.Bound(p => p.targetCurrency);
        columns.Bound(p => p.percentage);
        columns.Command(commands => { commands.Edit(); }); 
    }) 
    .Editable(edit =>
    {
        edit.Mode(GridEditMode.InLine); 
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
        .Model(model =>
        {
            model.Id(item => item.targetCurrency);  
        }) 
        .Events(events =>
        {
            events.Sync("onSync");
        })
        .Read(read => read.Action("ExchangeRate_Read", "ExchangeRatesFortius").Data("ReadRequestData"))
        .Update(c => c.Action("Currencies_Update", "ExchangeRatesFortius")) 
    )
)
@(Html.Kendo().Grid())
.名称(“ExchangeGrid”)
.列(列=>
{ 
columns.Bound(p=>p.targetCurrency);
columns.Bound(p=>p.percentage);
Command(commands=>{commands.Edit();});
}) 
.可编辑(编辑=>
{
编辑模式(GridEditMode.InLine);
})
.DataSource(DataSource=>DataSource
.Ajax()
.Batch(真)
.ServerOperation(错误)
.Model(Model=>
{
model.Id(item=>item.targetCurrency);
}) 
.Events(Events=>
{
事件同步(“onSync”);
})
.Read(Read=>Read.Action(“ExchangeRate\u Read”,“ExchangeRatesFortius”).Data(“ReadRequestData”))
.Update(c=>c.Action(“货币更新”、“汇率fortius”))
)
)

对于剑道mvc,我可以使用如下模板进行限制:

 columns.Bound(m => m.Inches)
                .ClientTemplate("<input type=\"number\" value=#= Inches # min=\"0\" max=\"11\" step=\"1\" ></input>")
                .Width(60);
columns.Bound(m=>m.Inches)
.ClientTemplate(“”)
.宽度(60);

你能给我们看一下你的网格创建代码吗?尽管你必须从选项中添加名称字段,例如,
$(“”)
,否则不会进行更新(不会获取值)