Skip to content
Advertisement

How to clear selected row in v-data-table, Vuetify

I have a Vue app where I’m using v-data-table with show-select option. I want to clear only selected data using the “cancel” button. Already I can clear all data from the table onclick.

Example in picture: I want to clear only the selected row (Ice cream sandwich)

enter image description here

Here is my code:

Table:

JavaScript

“cancel” button

JavaScript

script

JavaScript

Advertisement

Answer

If you just want to deselect them:

JavaScript

If you want to remove them:

JavaScript

Keep in mind that this array subtraction algorithm is O(n^2) complexity, so for large datasets this may be slow. In that case, you can use a more robust algorithm

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement