You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add support for reactivity in Vue-adapter (#5687)
* feat: add support for reactive data in Vue-adapter
* docs: update example to use reactivity
* add new in 8 20 callout to new docs
* ci: apply automated fixes
---------
Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/framework/vue/guide/table-state.md
+33-7Lines changed: 33 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,16 +13,44 @@ You do not need to set up anything special in order for the table state to work.
13
13
```ts
14
14
const table =useVueTable({
15
15
columns,
16
-
get data() {
17
-
returndata.value
18
-
},
16
+
data: dataRef, // Reactive data support
19
17
//...
20
18
})
21
19
22
20
console.log(table.getState()) //access the entire internal state
23
21
console.log(table.getState().rowSelection) //access just the row selection state
24
22
```
25
23
24
+
### Using Reactive Data
25
+
26
+
> **New in v8.20.0**
27
+
28
+
The `useVueTable` hook now supports reactive data. This means you can pass a Vue `ref` or `computed` containing your data to the `data`-option. The table will automatically react to changes in the data.
29
+
30
+
```ts
31
+
const columns = [
32
+
{ accessor: 'id', Header: 'ID' },
33
+
{ accessor: 'name', Header: 'Name' }
34
+
]
35
+
36
+
const dataRef =ref([
37
+
{ id: 1, name: 'John' },
38
+
{ id: 2, name: 'Jane' }
39
+
])
40
+
41
+
const table =useVueTable({
42
+
columns,
43
+
data: dataRef, // Pass the reactive data ref
44
+
})
45
+
46
+
// Later, updating dataRef will automatically update the table
47
+
dataRef.value= [
48
+
{ id: 1, name: 'John' },
49
+
{ id: 2, name: 'Jane' },
50
+
{ id: 3, name: 'Doe' }
51
+
]
52
+
```
53
+
26
54
### Custom Initial State
27
55
28
56
If all you need to do for certain states is customize their initial default values, you still do not need to manage any of the state yourself. You can simply set values in the `initialState` option of the table instance.
0 commit comments