Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / webdatagrid readonly cell in rowedit mode

webdatagrid readonly cell in rowedit mode

New Discussion
Mark Web
Mark Web asked on Jun 24, 2020 12:57 PM

hi,
i’m trying to disable (readonly) a cell in grid when i open the edit mode
how can i achieve that

Sign In to post a reply

Replies

  • 0
    Monika Kirkova
    Monika Kirkova answered on Jun 23, 2020 1:19 PM

    Hello Mark,

    After investigating this further, I determined that if your requirement is to disable edit of all cells in a certain column, “ReadOnly” property of the column could be set to true:

    <ig:CellEditing >

        <ColumnSettings>

                <ig:EditingColumnSetting ColumnKey="Fruit" ReadOnly="True" />

        </ColumnSettings>

    </ig:CellEditing >

    If you requirement is to disable cells in a column, depending on their value, a method could be bound to the enteringEditMode event the following way:

    <ig:CellEditing CellEditingClientEvents-EnteringEditMode="enteringEditMode">

    </ig:CellEditing>

    <script>

            function enteringEditMode(grid, eventArgs) {    

                var cell = eventArgs.getCell();

                if (cell.get_column().get_key() == "Fruit")

                {              

                    if (cell.get_element().textContent == "Apple") {

                         eventArgs.set_cancel(true);

                    }

                }

            }

        </script>

    Please test it on your side and let me know if you need additional information regarding this matter.

    Regards,

    Monika Kirkova,

    Infragistics

    • 0
      Mark Web
      Mark Web answered on Jun 23, 2020 1:22 PM

      hi,

      thank you that was helpful.

      but i need to get column index in code behind c# in order to save cell value !

      • 0
        Monika Kirkova
        Monika Kirkova answered on Jun 24, 2020 12:57 PM

        Hello Mark,

        The new value and the key of the edited cell could be accessed in the RowUpdating event. The event fires after at least one cell in the row has been edited and the focus is no longer on this row. e.Values contains the new values of the edited row and e.OldValues the old ones. The key and value could be accessed the following way:

        <ig:WebDataGrid ID="wdg" runat="server" Height="350px" Width="500px" DataKeyFields="ID" OnRowUpdating="wdg_RowUpdating">

        Default.aspx.cs:

        protected void wdg_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)

            {

                object changedCellValue;

                string changedCellKey = "";

                foreach (var column in columns)

                {

                    if(e.Values[column] != e.OldValues[column])

                    {

                        changedCellKey = column;

                        changedCellValue = e.Values[column];

                    }

                }        

            }

        Where columns is a list, where all columns are added when the data is loaded.

        Please let me know if you need additional information regarding this matter.

        Regards,

        Monika Kirkova,

        Infragistics

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Mark Web
Favorites
0
Replies
3
Created On
Jun 24, 2020
Last Post
5 years, 10 months ago

Suggested Discussions

Created by

Created on

Jun 24, 2020 12:57 PM

Last activity on

Feb 18, 2026 2:17 PM