简体   繁体   English

Kendo UI嵌入式网格

[英]Kendo UI Inline Grid

I am having an issue with validation on certain fields. 我在某些字段上的验证存在问题。 I want to only validate on a couple of fields, and the other fields should not validate. 我只想在几个字段上进行验证,而其他字段则不应该进行验证。 In my Email field, I am firing a function to check proper formatting, but the other fields are simply set to validate. 在我的电子邮件字段中,我启用了一个检查格式是否正确的函数,但其​​他字段只是设置为验证。 Any help would be greatly appreciated. 任何帮助将不胜感激。

 model: {
            id: "UserID",
            fields: {
                UserID: { editable: false },
                CompanyID: { editable: false },
                FirstName: { type: "string", validation: { required: { message: "Name is required"} } },
                LastName: { type: "string", validation: { required: { message: "Name is required" } } },
                Email: {
                    type: "string",
                    validation: {
                        required: { message: "Email is required." },
                        validateEmailFormat: function(input) {
                            if (input.attr("data-bind") == "value:Email") {
                                input.attr("data-validateEmailFormat-msg", "Email format invalid.");
                                return checkEmail(input.val());
                            }
                            return true;
                        }
                    }
                },
                PhoneNumber: { type: "string" },
                Extension: { type: "string" }
            }
        }

With this code, all fields are being validated when trying to save/update. 使用此代码,尝试保存/更新时将验证所有字段。 I don't want Extension or PhoneNumber to validate. 我不希望Extension或PhoneNumber进行验证。

In your update/Save action, You can remove your fields from the ModelState which don't want to valid, like : 在您的更新/保存操作中,您可以从ModelState删除不想生效的字段,例如:

ModelState.Remove("PhoneNumber");
ModelState.Remove("Extension");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM