Skip to main content Skip to footer

Disabling Drag and Drop with a Button Click in Vue

Background:

FlexGrid has a property called AllowDragging, which takes an enum and determines what users can and cannot do to a grid. We can tie this enum to a button that will allow a user to lock in rows and columns so they cannot be moved around the grid.

Steps to Complete:

1. Tie a method to the button click event

2. Set the allowDragging property of FlexGrid to '0', which prevents dragging and dropping columns

Getting Started

Tie a method to the button click event

Since this sample uses a button, we'll create a method called stopDragAndDrop(), which we'll then tie to the click event of the button.

<button (click)="stopDragAndDrop()">Disable Drag and Drop</button>

Set the allowDragging property of FlexGrid to '0', which prevents dragging and dropping columns

Then, in the JavaScript, we use mainGrid to reference our instance of FlexGrid, so all that needs done is to create the stopDragAndDrop() method and set the allowDragging property to 0 to disable drag and drop.

stopDragAndDrop() {
    this.mainGrid.allowDragging = 0;
}

Now, when the button is clicked, users won't be able to drag and drop columns inside of the grid.

Joel Parks