KendoUI 下拉框验证

转自:http://jsbin.com/elakul/2/edit


<!DOCTYPE html>

<html>
    <head>
        <title>KendoUI Test Page</title>
 
        <link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.common.min.css" rel="stylesheet" />
        <link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.default.min.css" rel="stylesheet" />
        <link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.dataviz.min.css" rel="stylesheet" />
        <link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.mobile.all.min.css" rel="stylesheet" />

        <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script src="http://cdn.kendostatic.com/2012.3.1114/js/kendo.all.min.js"></script>
    </head>
    <body>
        <div id="grid"></div>
        <script>
            $("#grid").kendoGrid({
                dataSource: {
                    data: [
                    {foo: 1, bar: 11},
                    {foo: 2, bar: 12},
                    {foo: 3, bar: 13},
                    {foo: 4, bar: 14},
                    {foo: 5, bar: 15},
                    {foo: 6, bar: 16},
                    {foo: 7, bar: 17}
                    ],
                    schema: {
                        model: {
                            id: "foo",
                            fields: {
                                foo: {type: "string", validation: { required: true } },
                                bar: {type: "number", validation: { required: true, min: 1 } }
                            }
                        }
                    }
                },
                columns: [
                {field: "foo", title: "Foo"},
                {field: "bar", title: "Bar", editor: barEditor},
                {command: ["edit", "destroy"]}
                ],
                editable: "inline",
                toolbar: ["create"]
            })

            function barEditor(container, options) {
                $('<input name="name" data-text-field="name" data-value-field="id" data-bind="value:' + options.field + '" required="required" />')
                .appendTo(container)
                .kendoComboBox({
                    autoBind: false,
                    dataSource: {
                        data: [
                        {name: "Name1", id: 1},
                        {name: "Name2", id: 2}
                        ]
                    }
                });
                $('$<span class="k-invalid-msg" data-for="name"></span>').appendTo(container);
            }
        </script>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值