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

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

4 Answers 1350 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sneha
Top achievements
Rank 1
Sneha asked on 31 Jul 2012, 01:26 PM
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";
        });     
    });

4 Answers, 1 is accepted

Sort by
0
Sneha
Top achievements
Rank 1
answered on 02 Aug 2012, 12:08 PM
Hi,
 I have resolved the issue using jquery.
Below is the code.
$('input[name *= "Username"]').attr("disabled", true);

Hope it helps someone.

Regards,
Sneha
0
Abhishek
Top achievements
Rank 1
answered on 17 Aug 2012, 07:46 AM
Thanks,

Its working for me.
0
Leo
Top achievements
Rank 1
answered on 22 Nov 2012, 10:40 PM
It's working perfect, thanks!
0
Robert
Top achievements
Rank 2
answered on 11 Oct 2016, 02:42 AM
Still working!  Thank you.
Tags
Grid
Asked by
Sneha
Top achievements
Rank 1
Answers by
Sneha
Top achievements
Rank 1
Abhishek
Top achievements
Rank 1
Leo
Top achievements
Rank 1
Robert
Top achievements
Rank 2
Share this question
or