vue-smart-table
Version:
A table with dynamic components for vue.js
73 lines (68 loc) • 2.24 kB
HTML
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>vuesmarttable</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.css" />
<style>
.smart-table {
margin: 25px;
}
</style>
</head>
<body>
<input type="text" v-model="search"/>
<smart-table
:auto-load="true"
body-path="results"
id-col="id.value"
table-classes="ui celled table unstackable"
endpoint="http://api.randomuser.me/?page=1&results=20&seed=abc"
:header="[
{key: 'name.first', label: 'name'},
{key: 'name.last', label: 'surname'},
{key: 'gender'},
{key: 'phone+cell', label: 'contacts'},
{key: 'picture.thumbnail', label: 'avatar'},
{key: 'nat', label: 'nationality'}
]"
:order-by="['name.first', 'name.last']"
:editable="['name.first', 'name.last', 'picture.thumbnail']"
:can-filter-by="['name.first', 'name.last']"
v-ref:smart>
<plain-text col="name.first" :multiline="true"></plain-text>
<!-- this component is used implicitly
you can write it if you want to tweak
its configuration -->
<src2img col="picture.thumbnail"></src2img>
<!-- this component will read the image
address inside the nested json
object and put it into the scr of
an img tag -->
<contacts col="phone+cell"></contacts>
<!-- every derived column needs a component
to be displayed correctly this
component is just a <p> tag and some
styling -->
<fontawesome col="gender"></fontawesome>
<!-- this last component is pretty self
explanatory, it will turn the string
into the specified icon -->
<nationality col="nat"></nationality>
<!-- this component will take the country
iso code from the json, query
a web service and overwrite itself with
the full country name! -->
</smart-table>
<smart-table
:body="[{hello:'world'},{world:'hello'}]"
>
</smart-table>
<smart-table
:body="[{'hello world':'hi'}]"
>
</smart-table>
<!-- built files will be auto injected -->
</body>
</html>