Find Column Names during Edit Event with Frozen Locked Columns

3 posts, 0 answers
  1. Darron
    Darron avatar
    8 posts
    Member since:
    Jul 2016

    Posted 18 Jan Link to this post

    As I understand it, when you have locked column in the grid there will be two separate table elements for the data items - one for locked columns and one for the regular ones.  I haven't stumbled across how to address the two separate table elements separately.  The code below works beautifully until you start locking columns.  If any columns are locked, the fieldName will wind up containing the name of an adjacent column.

     I need to determine how to get the correct column names during edit regardless of their locked/unlocked condition.  Any help or suggestions are greatly appreciated.  -Darron

    <script>

        var currentItem;
        var currentColumn;

        function grid_edit(e) {
            var grid = this;
            var model = grid.dataItem(grid.current().closest("tr"));
            currentItem = model;
            var fieldName = grid.columns[e.container.index()].field;
            currentColumn = fieldName;
            if (currentColumn == "Contact" || currentColumn == "ShipFrom" || currentColumn == "ShipTo")
            {
                showModalPopUp(currentColumn);
            }

    } </script>

  2. Darron
    Darron avatar
    8 posts
    Member since:
    Jul 2016

    Posted 18 Jan in reply to Darron Link to this post

    I found a way to get the input/column name consistently during edit event without getting thrown off by locked columns.

        function grid_edit(e) {
            var grid = this;
            var model = grid.dataItem(grid.current().closest("tr"));
            currentItem = model;      
            var ec0 = e.container[0];
            var fEC = ec0.firstElementChild;
            currentColumn = fEC.id; 

            if (currentColumn == "Contact" || currentColumn == "ShipFrom" || currentColumn == "ShipTo")
            {
                showModalPopUp(currentColumn);
            }

    }

    Please someone tell me if I'm shooting myself in the foot here and/or giving a bad solution.  -Darron

  3. Stefan
    Admin
    Stefan avatar
    2057 posts

    Posted 22 Jan Link to this post

    Hello, Darron,

    The provided approach looks good.

    I only noticed that there is additional code to retrieve the model, but the model is directly available in the event as "e.model":

    https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/edit#edit

    Also, the code has to be revisited if the column order has changed.

    If there is an issue with the approach in the future, please let us know and we will gladly assist further.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top