如何将MINIMUM值应用于Kendo网格列输入框?

时间:2013-08-26 19:04:53

标签: jquery html kendo-grid

代码:

function directorsOrRecipients(e)
{
    $("<div/>").appendTo(e.detailCell).kendoGrid({
        dataSource: {
            transport: {
                read: { url: "http:...xxxx" + e.data.AwardTitleId, type: "GET" }
            },
            schema: {
                model: {
                    id: "namefirstlast",
                    fields: {
                        "namefirstlast": { editable: true, type: "string" },
                        "directorsequence": { editable: true, type: "number" },
                        "isonballot": { editable: true, type: "boolean" },
                        "concatenation": { editable: true, type: "string" },
                        "MoreNames": { editable: true, type: "number" },
                    }
                },
            }
        },
        columns: [
            { field: "namefirstlast", title: "Name", editor: namesAutoComplete },
            { field: "directorsequence", title: "Director Sequence", format: "{0:n0}" },
            { field: "isonballot", title: "On ballot?" },
            { field: "concatenation", title: "Concatenation" },
            { field: "MoreNames", title: "More names?", format: "{0:n0}"},
            { command: ["edit"], title: "&nbsp;", width: "100px" }],
        sortable: true,
        editable: "inline",
        toolbar: [{ name: "create", text: "Add New Director/Recipient" }]
    });
}

我想确保用户只能在MoreNames列中输入0或更大的数字。没有负数。

请注意,此网格由Kendo生成,因此它不是我创建的简单HTML结构。

这是我所关注的文本框的DOM对象:

<input type="text" name="MoreNames" data-type="number" data-bind="value:MoreNames" data-role="numerictextbox" role="spinbutton" class="k-input" aria-disabled="false" aria-readonly="false" style="display: none;">

我尝试选择此对象并添加“min”属性但我无法选择它会让我相信我选择的方式不正确。

这就是我的尝试:

$("[name='MoreNames']").attr("min", "0");

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:6)

我明白了:

schema: {
                model: {
                    id: "namefirstlast",
                    fields: {
                        "namefirstlast": { editable: true, type: "string" },
                        "directorsequence": { editable: true, type: "number" },
                        "isonballot": { editable: true, type: "boolean" },
                        "concatenation": { editable: true, type: "string" },
                        "MoreNames": { editable: true, type: "number", validation: { min: 0 } },
                    }
                },
            }
        },