Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 10, 2021. It is now read-only.

A vue.js component to create dynamic tables

License

NotificationsYou must be signed in to change notification settings

coderdiaz/vue-datasource

Repository files navigation

Vue Datasource

A Vue.js server side component to create dynamic tables. Compatible with Vue 2.x and Laravel.


Demo

forthebadgeforthebadge

'Screenshot'

Live:https://young-falls-97690.herokuapp.com/

Install/Usage

$ npm install vue-datasource
<divid="#app"><datasourcelanguage="en":table-data="information.data":columns="columns":pagination="information.pagination":actions="actions"v-on:change="changePage"v-on:searching="onSearch"></datasource></div>
importDatasourcefrom'vue-datasource'newVue({el:'#app',components:{        Datasource},data(){return{information:{pagination:{...},data:[...]},columns:[...],actions:[...]}},methods:{changePage(values){...},onSearch(searchQuery){...}}});

Available Props

PropTypeDefaultDescription
table-dataArrayTable information
languageStringesDefines the table labels language
columnsArrayColumns to display
paginationObjectPagination information about the table data ([structure] (#pagination-structure))
actionsArrayAction buttons ([structure] (#action-event-sctructure))

Available Events

EventDescription
changeHandle show limit changed. Gets object with new show limit and current page{perpage: 10, page: 2}
searchingHandles search input. Gets string as parameter

Available Languages

LanguageAbbr
Spanishes
Englishen
Frenchfr

Columns

Each column object needs aname andkey attributes.

{    ...,columns:[{name:'Name',// Table column name to displaykey:'name',// Key name from row object}]}

For Laravel users, you can access relationships through thekey attribute. Lets say we have the following object in our users array.

[    ...,{name:'Foo',last_name:'Bar'role_id:1,role:{name:'admin'}}]

To get the user's role we would need to define in our columns array:

{    ...,columns:[{name:'Role',key:'role.name'}]}

Render column

This callback will modify the data for various operations. Such as applying a specific format or an arithmetic operation to the column value and return it.

{    ...,columns:[{name:'Name',key:'name',render(value){// Render callbackreturn`Enginner${value}`;}}]}

Pagination Structure

{    ...,pagination:{total:25,// Number of total rows (default 0)per_page:15,// Number of rows to show (default 15)current_page:1,// Actual pagelast_page:2,// Last pagefrom:1,// Beginning of visible rowsto:15// End of visible rows}}

Action Event Sctructure

{    ...,actions:[{text:'Click me',// Button labelicon:'glyphicon glyphicon-check',// Button iconclass:'btn-primary',// Button class (background color)event(e,row){// Event handler callback. Gets event instace and selected rowconsole.log('Click row: ',row);// If no row is selected, row will be NULL}}]}

Implementation examples

Contributions

All contributions are welcome send your PR and Issues.

License

Vue Datasource is open-sourced software licensed under theMIT license

Created by Javier Diaz. Translation enhancement by [itsuwaribito] (https://github.com/itsuwaribito)

About

A vue.js component to create dynamic tables

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp