Kendo Grid schema.model.fields按键上的字段验证?

时间:2019-04-08 11:45:41

标签: kendo-grid

在输入字段中按下键时,我可以创建Kendo Grid模式>模型>字段> my_field>验证,而不是创建函数并调用它们吗?

schema: {

    model: {
        fields: {                                   
            field: { type: "string",
            validation: {                                                            
                ifieldValidation: function (input) { 
                //  My code here. Instead of putting all this in separate function can I trigger this validation somehow?
                return true;
                }
            return true;
            }
        },   
    },

...更多字段

$("#myselector").on("keydown", ".input-field", function (e) {
  // instead of creating functions and calling those, can I trigger the Kendo Grid schema > model > fields > my_field > validation for example call the ifieldValidation ?
});

1 个答案:

答案 0 :(得分:0)

我刚刚找到了解决方案,所以我在回答我的问题,以防有人也需要它:

$("#mygrid").on("keydown", ".my-input", function (e) {
mygrid.options.schema.model.fields.myfieldname.validation.mycustomvalidationfunction($(this));
});