user3202524
user3202524

Reputation: 43

Kendo grid data("kendoValidator").validate() method always returns true

$("#mygrid").kendoValidator().data("kendoValidator").validate() method always returns true even if there are validation errors for some of the input fields in the grid. On first time load the validation works fine but during edit the next time it does not show the tooltip, please help me resolve this issue.

I have added a validation template using schema of the grid:

schema: {
    model: {
        id: "AuctionID",
        fields: {
            AuctionID: {
                editable: false,
                type: "number"
            },
            AuctionName: {
                type: "string",
                validation: {
                    required: { message: "An Auction Name is Required!" },
                    validateAuctionName: function (input) {
                        if (input.attr("data-bind") == "value:AuctionName") { // check if this is the element to validate
                            alert(input.val().length);
                            if (input.val().length > 10) {
                                input.attr("data-validateAuctionName-msg", "AuctionName can only have a maximum of 10 characters.");
                                return false;
                            }
                            else
                                return true;
                        }
                        return true;
                    }
                }
            }
        }
    }
}

Upvotes: 1

Views: 5975

Answers (1)

root
root

Reputation: 2357

The method you are using is not triggering validation as it interrogates "this" and validates it if it is a kendo widget with validation enabled.

I found this way to force validation - get hold of model and trigger change on property you want to validate:

model.trigger("set", { field: "FinishTime", value: model.FinishTime });

Upvotes: 2

Related Questions