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

Find Column Names during Edit Event with Frozen Locked Columns

2 Answers 228 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darron
Top achievements
Rank 1
Darron asked on 18 Jan 2018, 09:03 PM

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 Answers, 1 is accepted

Sort by
0
Darron
Top achievements
Rank 1
answered on 18 Jan 2018, 10:13 PM

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

0
Stefan
Telerik team
answered on 22 Jan 2018, 08:08 AM
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.
Tags
Grid
Asked by
Darron
Top achievements
Rank 1
Answers by
Darron
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or