# Prevent Reordering of Non-Locked Columns into Locked Section in Grid

## Environment

<table>
    <tbody>
        <tr>
            <td>Product</td>
            <td>Progress® Kendo UI® for Angular Grid</td>
        </tr>
    </tbody>
</table>

## Description

I want to prevent non-locked columns from moving into the [locked columns](https://www.telerik.com/kendo-angular-ui/components/grid/columns/locked) section when I [reorder columns](https://www.telerik.com/kendo-angular-ui/components/grid/columns/reordering) in the Kendo UI for Angular Grid. How can I restrict column reordering between locked and non-locked sections?

This Knowledge Base article also answers the following questions:

* How can I stop non-locked columns from moving into the locked section?
* Is it possible to prevent columns from moving between locked and non-locked areas?
* Can I handle the column reorder event to restrict specific column movements?

## Solution

To prevent non-locked columns from being reordered into the locked section, handle both the [`columnReorder`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#columnReOrder) and [`columnLockedChange`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#columnLockedChange) events.

When a column reorder operation attempts to cross the locked/unlocked boundary, the Grid fires the `columnLockedChange` event. You can handle this event to revert the previous column state and prevent the reorder process using the Grid's built-in [state management](https://www.telerik.com/kendo-angular-ui/components/grid/persist-state) feature.

1. Add a flag to track when a reorder operation is in progress:

   ```typescript
   private isReordering: boolean = false;
   ```

2. Handle the `columnReorder` event to save the current column state and set the reordering flag:

   ```typescript
   public onReorder(grid: GridComponent): void {
     this.savedColumnsState = grid.currentState.columnsState;
     this.isReordering = true;
   }
   ```

   The [`currentState.columnsState`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridstate#columnsstate) property captures the complete column configuration before the Grid processes the reorder.

3. Handle the `columnLockedChange` event to detect and revert locked state changes that occur during reordering. You can use the [`loadState`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#loadstate) method to restore the saved column state when `isReordering` is `true`:

   ```typescript
   public onLockedChange(grid: GridComponent): void {
     if (this.isReordering) {
       this.isReordering = false;
       setTimeout(() => {
         grid.loadState({ columnsState: this.savedColumnsState });
       });
     }
   }
   ```

The following example demonstrates the suggested approach in action. Try dragging columns across the locked boundary to see the restrictions in effect.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/grid-restrict-columns-moving-into-locked/source.txt)

## See Also

* [Managing the Angular Data Grid State](https://www.telerik.com/kendo-angular-ui/components/grid/persist-state)
* [API Reference of the GridComponent](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent)
* [API Reference of the ColumnReorderEvent](https://www.telerik.com/kendo-angular-ui/components/grid/api/columnreorderevent)
* [API Reference of the ColumnLockedChangeEvent](https://www.telerik.com/kendo-angular-ui/components/grid/api/columnlockedchangeevent)
