Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
435
Correct way to Allow Adding of a New Row but disable editing of a single column
posted

I have a unique requirement:

My current jQuery grid works fine. Currently I have editing enabled (Features => updating). Anyhow, I have to disable editing of a specific column once added. So basically, if someone add's a record they should be able to enter "Col A, B, C, D". However if they edit, only Columns A, B, and D should be editable.

Changing the column properties for updating to Read-Only for the column also affects adding a new row. Is there any way around this?

Parents
No Data
Reply
  • 23953
    Verified Answer
    Offline posted

    Hi,

    You can easily accomplish this in cell update mode by handling the igGridUpdating.editCellStarting event and check the ui.rowAdding parameter. Here is the code:

    features: [{

        name: "Updating",

        mode: "cell",

        editCellStarting: function (evt, ui) {

            if ((ui.rowAdding == false) && (ui.columnKey == "Name")) {

                return false;

            }

        }

    }]

     

    For update mode row you should handle igGridUpdating.editRowStarted, check the ui.rowAdding and show/hide the column editor by using the igGridUpdating.editorForKey API.

    Here is the code:

    features: [

        {

            name: "Updating",

            mode: "row",

            editRowStarted: function (evt, ui) {

                if (ui.rowAdding == false) {

                    var editor = $("#grid1").igGridUpdating("editorForKey", "Name");

                    $(editor).igEditor("hide");

                }

                else

                {

                    var editor = $("#grid1").igGridUpdating("editorForKey", "Name");

                    $(editor).igEditor("show");

                }

            }

        }

    ]

     

    Hope this helps,

    Martin Pavlov

    Infragistics, Inc.

Children