HC200ok / vue3-easy-data-table

A customizable and easy-to-use data table component made with Vue.js 3.x
MIT License
536 stars 105 forks source link

items-selected reactivity for multiple tables #327

Open RealFoxie opened 1 year ago

RealFoxie commented 1 year ago

I have a page with multiple (dynamic) tables, where every table has selections.

I tried to approach this as follows: dynamically set items-selected: v-model:items-selected="selection[index]"> with selection being letselection: Ref<Item[]>[] = []; And filling it (I tried multiple ways, none seemed to make a difference): selection = Array(amountOfTables).fill(ref<Item[]>([]))

In principle I see no difference with the example: selection[index] refers to a ref<Item[]>([]) as the documentation specifies. It does not work though. The reactivity is broken.

Is this just not possible, or is some other setup needed to make this work?

Workaround: Use one variable for selections in all tables. If your tables hasduplicate values, add something unique like an id (items-selected works with the json-representation to see if an item is the same). Note that this doesn't work great: e.g. the select-all button will delete all selections of other tables.