Making column as readonly on update and editable on insert in grid

5 posts, 0 answers
  1. Sneha
    Sneha avatar
    6 posts
    Member since:
    Jul 2012

    Posted 31 Jul 2012 Link to this post

    Hi,

    I have a username field which should be editable on insert and readonly on update. I have written code marked in bold below to achieve this but it is working only for the first time. Disabled property is not getting set as false. Any ideas on how to resolve the issue??

                editable: "popup",
                edit: function (e) {
                    debugger;
                    if (isCreating) {
                        var window = e.container.data("kendoWindow");
                        window.title("Add new record");
                        e.container.find("a.k-grid-update").html('<span class="k-icon k-update"></span>Create');
                        //reset the flag
                        isCreating = false;
                    }
                    else {
                        //e.container.find("k-input k-textbox").html('<input type="text" class="k-input k-textbox" name="Username" disabled="true"/>');
                        document.getElementsByName("Username")[0].disabled = "true";
                    }
                }
            });
            $(".k-grid-add").on("click", function (e) {
                debugger;
                isCreating = true;
                document.getElementsByName("Username")[0].disabled = "false";
            });     
        });
  2. Sneha
    Sneha avatar
    6 posts
    Member since:
    Jul 2012

    Posted 02 Aug 2012 Link to this post

    Hi,
     I have resolved the issue using jquery.
    Below is the code.
    $('input[name *= "Username"]').attr("disabled", true);

    Hope it helps someone.

    Regards,
    Sneha
  3. Kendo UI is VS 2017 Ready
  4. Abhishek
    Abhishek avatar
    7 posts
    Member since:
    Jul 2012

    Posted 17 Aug 2012 Link to this post

    Thanks,

    Its working for me.
  5. Leo
    Leo avatar
    3 posts
    Member since:
    Mar 2012

    Posted 22 Nov 2012 Link to this post

    It's working perfect, thanks!
  6. Robert
    Robert avatar
    3 posts
    Member since:
    Mar 2015

    Posted 10 Oct Link to this post

    Still working!  Thank you.
Back to Top
Kendo UI is VS 2017 Ready