JSFiddle - React, Tailwind, and code Playground
by WILLIAM CORREA
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.7/semantic.min.css">
<script src="https://rawgit.com/ratiw/vuetable-2/develop/dist/vuetable-2.js"></script>
<div id="app">
<div class="ui container">
<vuetable ref="vuetable"
api-url="https://vuetable.ratiw.net/api/users"
:fields="fields"
pagination-path=""
@vuetable:pagination-data="onPaginationData"
>
<template slot="actions" scope="props">
<div class="table-button-container">
<button class="ui button" @click="editRow(props.rowData)">
<i class="fa fa-edit"></i> Edit
</button>
<button class="ui basic red button" @click="deleteRow(props.rowData)"><i class="fa fa-remove"></i> Delete</button>
</div>
</template>
</vuetable>
<vuetable-pagination ref="pagination"
@vuetable-pagination:change-page="onChangePage"
></vuetable-pagination>
</div>
</div>
CSS
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
JavaScript
Vue.use(Vuetable);
new Vue({
el: '#app',
components:{
'vuetable-pagination': Vuetable.VuetablePagination
},
data: {
fields: ['name', 'email','birthdate','nickname','gender','__slot:actions']
},
computed:{
/*httpOptions(){
return {headers: {'Authorization': "my-token"}} //table props -> :http-options="httpOptions"
},*/
},
methods: {
onPaginationData (paginationData) {
this.$refs.pagination.setPaginationData(paginationData)
},
onChangePage (page) {
this.$refs.vuetable.changePage(page)
},
editRow(rowData){
alert("You clicked edit on"+ JSON.stringify(rowData))
},
deleteRow(rowData){
alert("You clicked delete on"+ JSON.stringify(rowData))
}
}
})