Grid Validation confusion!

2 posts, 0 answers
  1. Ratan
    Ratan avatar
    2 posts
    Member since:
    Apr 2016

    Posted 10 Apr Link to this post



    I am  new to Kendo and I am facing a very confusing problem that i cant solve.


    I have a grid which contains 5 columns like so - RoleName, Description, isActive, isDeleted, Action.

    Now i have validation just on the RoleName Column.


    My issue is, I should not let the user Input duplicate RoleName on edit or on creating a new record. For example, RoleName = Admin already exists on the grid and when the user creates a new record he shouldn't be able to enter Admin again, i got this part to work however when the user edits the already existing row which contains "Admin" as the rolename and changes isActive, the validation fires again telling Admin already exists and i cant edit that row. How do i fix this?


    fields: {
                                Id: { type: "number", editable: false },
                                RoleName: {
                                    type: "string",
                                    validation: {
                                        required: true,
                                        validateOnBlur: false,
                                        rolenameValidation: function (input) {
                                            if ("[name='RoleName']") && input.val() !== "" && NetAppAssetRecoveryRoleAdminMethods.IfRoleNameExists(input.val())) {
                                                input.attr("data-rolenameValidation-msg", "Role Name already exists");
                                                return false;
                                            else if (NetAppAssetRecoveryRoleAdminMethods.IfRoleNameExists(input.val()) == undefined)
                                                input.attr("data-rolenameValidation-msg", "Role Name can contain only characters");
                                                return false;
                                            return true;


  2. Konstantin Dikov
    Konstantin Dikov avatar
    1755 posts

    Posted 14 Apr Link to this post

    Hi Ratan,

    The behavior that you are describing is expected, because the validation will fire again when you change another field in that row and when that happens, your IfRoleNameExists method returns true. One thing that you can try is to include the ID of that row as a parameter and skip that ID while checking the items.

    Hope this helps.

    Konstantin Dikov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. DevCraft R3 2016 release webinar banner
Back to Top