<template>
<grid
:auto-width="autoWidth"
:cols="cols"
:from="from"
:language="language"
:pagination="pagination"
:rows="rows"
:search="search"
:server="server"
:sort="sort"
:width="width"
></grid>
</template>
<script>
import Grid from 'gridjs-vue'
export default {
name: 'MyTable',
components: {
Grid
},
data() {
return {
cols: ['col 1',
'col 2'],
rows: [
['row 1 col 1', 'row 1 col 2'],
['row 2 col 1', 'row 2 col 2']
],
from: '.my-element'
server() ({
url: 'https://api.com/search?q=my%20query',
then: res => res.data.map(col => [col1.data, col2.data]),
handle: res => res.status === 404
? { data: [] } : res.ok
? res.json() : new Error('Something went wrong')
}),
autoWidth: true / false,
language: {},
pagination: true / false || {},
search: true / false || {},
sort: true / false || {},
theme: 'mermaid',
width: '100%',
}
}
}
</script>