|
1 |
| -## Vue Datasource |
2 |
| -### A Vue.js component to create tables from Server Side |
3 |
| -#### Compatible with Vue 2.x |
| 1 | +# Vue Datasource |
| 2 | +#### A Vue.js component to create tables from Server SideCompatible with Vue 2.x |
4 | 3 |
|
5 |
| - |
| 4 | +### Demo |
6 | 5 |
|
7 |
| -Coming soon.. |
| 6 | + |
| 7 | + |
| 8 | +Coming soon live demo ... |
| 9 | + |
| 10 | +### Install/Usage |
| 11 | +``` |
| 12 | +$ npm install vue-datasource |
| 13 | +``` |
| 14 | + |
| 15 | +```html |
| 16 | + <div id="#app"> |
| 17 | + <datasource |
| 18 | + language="en" |
| 19 | + :table-data="information.data" |
| 20 | + :columns="columns" |
| 21 | + :pagination="users.pagination" |
| 22 | + :actions="actions" |
| 23 | + v-on:change="changePage" |
| 24 | + v-on:searching="onSearch"></datasource> |
| 25 | + </div> |
| 26 | +``` |
| 27 | + |
| 28 | +```javascript |
| 29 | +import Datasource from 'vue-datasource' |
| 30 | + |
| 31 | +new Vue({ |
| 32 | + el: '#app', |
| 33 | + components: { |
| 34 | + Datasource |
| 35 | + }, |
| 36 | + data() { |
| 37 | + return { |
| 38 | + information: { |
| 39 | + pagination: {...}, |
| 40 | + data: [...] |
| 41 | + }, |
| 42 | + columns: [...], |
| 43 | + actions: [...] |
| 44 | + } |
| 45 | + }, |
| 46 | + methods: { |
| 47 | + changePage(values) {...}, |
| 48 | + onSearch(searchQuery) {...} |
| 49 | + } |
| 50 | +}); |
| 51 | +``` |
| 52 | + |
| 53 | +### Available Props |
| 54 | +| Prop | Type | Default | Description | |
| 55 | +|-------------|---------|---------|-------------------------------------------------------------| |
| 56 | +| tableData | Array | | The table information to display | |
| 57 | +| language | String | es | Defines the language with which the table will be displayed | |
| 58 | +| columns | Array | | Columns to display in table | |
| 59 | +| pagination | Object | | Information about data collection to paginate | |
| 60 | +| actions | Array | | Buttons to perform action on click event | |
| 61 | + |
| 62 | +### Available Events |
| 63 | +| Event | Description | |
| 64 | +|-------------|------------------------------------------------| |
| 65 | +| change | Return the limit per page and the current page | |
| 66 | +| searching | Return the string to search | |
| 67 | + |
| 68 | +### Render column value with custom format |
| 69 | +To show the value of a column with a custom format uses the render property, this will allow you to get the original value and return it in the way you define. |
| 70 | +```javascript |
| 71 | +{ |
| 72 | + ..., |
| 73 | + columns: [ |
| 74 | + { |
| 75 | + name: 'Name', // Header name column |
| 76 | + // Name of column on table. If you are working in Laravel |
| 77 | + // you can access the relationships using 'relation.key' |
| 78 | + key: 'name', |
| 79 | + render(value) { |
| 80 | + return `Enginner ${value}`; |
| 81 | + } |
| 82 | + } |
| 83 | + ] |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +### Implementation examples |
| 88 | +- Using Laravel 5.3 and pagination: [laravel-datasource-example](https://github.com/coderdiaz/laravel-datasource-example). |
| 89 | + |
| 90 | +_You can add implementations send me your PR._ |
| 91 | + |
| 92 | +### Contributions |
| 93 | +All contributions are welcome send your PR and Issues. |
| 94 | + |
| 95 | +Created by Javier Diaz |
0 commit comments