This is a migrated thread and some comments may be shown as answers.

Custom Validator for Grid columns

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
N
Top achievements
Rank 1
N asked on 02 Jan 2014, 03:56 AM
The validation is working good, but does not display the error message in the grid cell.
I have tried couple of options, even though it enters into the logic and fails the validation, no message is displayed.

  $.extend(true, kendo.ui.validator, {
                rules: {
                    // custom rules
                    OrgSchoolID: function (input) {
                                //console.log("Custom Validator fired");
                                // all of the input must have a value
                                //return $.trim(input.val()) !== "";
                                if (input.is("[name=OrgID_FK]") && input.val() === "")
                                    return false;
                                else
                                    return true;

                            },
                },
                messages: { //custom rules messages
                    OrgSchoolID: function (input) {
                        // return the message text
                        return "OrgName is required!";
                    }
                }
            });
===============================================================================================================================

I tried this options as well, even though it steps into correctly during debug and returns fail, the Error message is not displayed

 OrgID_FK: {
                        editable: true,
                        type: "number",
                        validation: {
                                IsOrgIDValid: function (input) {
                                            console.log("Validation fired for ORgID Column");
                                            if (input.is("[name=OrgID_FK]") && input.val() === "") {
                                                console.log("Validation failed for OrgID_FK");
                                                input.attr("data-IsOrgIDValid-msg", "OrgName is required!");
                                                return false;
                                            }
                                            return true;
                                        }
                                  
                            } // validation
                    }, // OrgID_FK

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 02 Jan 2014, 08:25 AM
Hello,

The following demo illustrates how custom validation rule should used in the context of the Grid widget:
http://demos.kendoui.com/web/grid/editing-custom-validation.html


Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
N
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or