vue-table
data table simplify! -- vuetable is a Vue.js component that will automatically request (JSON) data from the server and display them nicely in html table with swappable/extensible pagination component.
Top Related Projects
Vue.js 2 grid components
An easy to use powerful data table for vuejs with advanced customizations including sorting, column filtering, pagination, grouping etc
A powerful data table based on vuejs. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.
A simple, customizable and pageable table with SSR support, based on vue2 and element-ui
Quick Overview
Vue-table is a Vue.js component for creating dynamic data tables with features like sorting, filtering, and pagination. It provides a flexible and customizable solution for displaying tabular data in Vue applications, making it easier to handle large datasets and improve user experience.
Pros
- Easy integration with Vue.js projects
- Supports sorting, filtering, and pagination out of the box
- Highly customizable with various props and slots
- Responsive design for different screen sizes
Cons
- Limited documentation and examples
- May have performance issues with very large datasets
- Not actively maintained (last update was in 2019)
- Some reported bugs and compatibility issues with newer Vue versions
Code Examples
- Basic table setup:
<template>
<vue-table :columns="columns" :data="data"></vue-table>
</template>
<script>
import VueTable from 'vue-table';
export default {
components: { VueTable },
data() {
return {
columns: ['name', 'age', 'city'],
data: [
{ name: 'John', age: 30, city: 'New York' },
{ name: 'Jane', age: 25, city: 'London' },
],
};
},
};
</script>
- Adding sorting and filtering:
<template>
<vue-table
:columns="columns"
:data="data"
:sortable="['name', 'age']"
:filterable="['city']"
></vue-table>
</template>
- Custom column rendering:
<template>
<vue-table :columns="columns" :data="data">
<template v-slot:age="props">
{{ props.row.age }} years old
</template>
</vue-table>
</template>
Getting Started
-
Install the package:
npm install vue-table
-
Import and use the component in your Vue file:
<template> <vue-table :columns="columns" :data="data"></vue-table> </template> <script> import VueTable from 'vue-table'; export default { components: { VueTable }, data() { return { columns: ['name', 'age', 'city'], data: [ { name: 'John', age: 30, city: 'New York' }, { name: 'Jane', age: 25, city: 'London' }, ], }; }, }; </script>
-
Customize the table by adding props for sorting, filtering, or pagination as needed.
Competitor Comparisons
Vue.js 2 grid components
Pros of vue-tables-2
- More comprehensive feature set, including server-side operations and advanced filtering
- Better documentation and examples
- Active development and maintenance
Cons of vue-tables-2
- Steeper learning curve due to more complex API
- Larger bundle size, which may impact performance for simpler use cases
Code Comparison
vue-tables-2:
<v-client-table :data="tableData" :columns="columns" :options="options">
<template slot="actions" slot-scope="props">
<button @click="editRow(props.row)">Edit</button>
</template>
</v-client-table>
vue-table:
<vue-table :columns="columns" :data="tableData">
<template slot="actions" slot-scope="{ row }">
<button @click="editRow(row)">Edit</button>
</template>
</vue-table>
Both libraries offer similar basic functionality, but vue-tables-2 provides more advanced features out of the box. vue-table is simpler and may be easier to set up for basic use cases, while vue-tables-2 offers more flexibility and power for complex table requirements. The choice between the two depends on the specific needs of your project and the level of customization required.
An easy to use powerful data table for vuejs with advanced customizations including sorting, column filtering, pagination, grouping etc
Pros of vue-good-table
- More feature-rich, including advanced sorting, filtering, and pagination
- Better documentation and examples
- Active development and maintenance
Cons of vue-good-table
- Larger bundle size due to more features
- Steeper learning curve for complex use cases
Code Comparison
vue-good-table:
<vue-good-table
:columns="columns"
:rows="rows"
:search-options="{
enabled: true
}"
:pagination-options="{
enabled: true
}"
/>
vue-table:
<v-table
:data="tableData"
:columns="columns"
:filter-key="searchQuery">
</v-table>
vue-good-table offers more built-in features like search and pagination, while vue-table requires additional implementation for these functionalities. vue-good-table's syntax is more declarative, making it easier to configure advanced options directly in the component.
Both libraries provide similar basic functionality, but vue-good-table offers a more comprehensive solution out of the box. vue-table may be preferable for simpler use cases or when a smaller bundle size is crucial. However, for projects requiring advanced table features, vue-good-table is likely the better choice due to its richer feature set and active maintenance.
A powerful data table based on vuejs. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.
Pros of vue-easytable
- More comprehensive documentation and examples
- Supports virtual scrolling for large datasets
- Offers more advanced features like cell editing and column filtering
Cons of vue-easytable
- Larger bundle size due to more features
- Steeper learning curve for complex configurations
- Less frequent updates compared to vue-table
Code Comparison
vue-easytable:
<template>
<ve-table :columns="columns" :table-data="tableData" />
</template>
<script>
import { VeTable } from 'vue-easytable'
</script>
vue-table:
<template>
<v-table :data="tableData" :columns="columns" />
</template>
<script>
import { VTable } from 'vue-table'
</script>
Both libraries offer similar basic usage, but vue-easytable provides more built-in features and customization options. vue-table focuses on simplicity and ease of use, while vue-easytable offers a more feature-rich experience at the cost of increased complexity.
vue-easytable is better suited for projects requiring advanced table functionality, while vue-table is ideal for simpler use cases where a lightweight solution is preferred. Consider your project's specific needs and performance requirements when choosing between these two libraries.
A simple, customizable and pageable table with SSR support, based on vue2 and element-ui
Pros of vue-data-tables
- More comprehensive documentation and examples
- Built-in support for server-side pagination and sorting
- Offers more customization options for table appearance and behavior
Cons of vue-data-tables
- Steeper learning curve due to more complex API
- Larger bundle size, which may impact performance for simpler use cases
Code Comparison
vue-table:
<v-table
:data="tableData"
:columns="columns"
:sort-order="sortOrder"
@sort-change="handleSortChange"
/>
vue-data-tables:
<data-tables
:data="tableData"
:actions-def="actionsDef"
:pagination-def="paginationDef"
:search-def="searchDef"
>
<el-table-column v-for="col in columns" :key="col.prop" :prop="col.prop" :label="col.label" />
</data-tables>
Both libraries provide Vue components for creating data tables, but vue-data-tables offers more built-in features and customization options. vue-table has a simpler API, making it easier to get started with basic table functionality. vue-data-tables is better suited for complex use cases with server-side operations and advanced filtering, while vue-table may be preferable for simpler, client-side tables with minimal configuration.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Please Note!
This is the previous version that works with Vue 1.x. The most up-to-date version is the Vuetable-2. If you like it, please star the Vuetable-2 repo instead, or make a small donation to support it.
This version is "no longer supported" as I do not have time to maintain different version.
vuetable - data table simplify!
- No need to render the table yourself
- One simple
vuetable
tag - Display data retrieved from server with sort options
- Support multi-column sorting (v1.2.0) by @balping
- Pagination component included, swap-able and extensible
- Define fields to map your JSON data structure
- Define row actions and capture the click event to do whatever you want
- Field display customizable via callback function inside Vue.js instance
- Programmatically show/hide any field via reactivity of fields definition
- Use your favorite CSS framework classes to nicely format your table and displayed data
- Events to allow control from Vue.js instance programmatically
- Capture events from
vuetable
to manipulate your table and your data - Should work with any pre-defined JSON data structure
- Should work with any CSS Framework, e.g. Semantic UI, Twitter's Bootstrap
- Optional detail row to display additional data (v.1.2.0)
vuetable is only working for Vue 1.x, vuetable-2 is for Vue 2.x
If you're looking for the version that's working with Vue 2.x, please go to vuetable-2
repo. However, I still have no time to work on the documentation. But if you're familiar enough with vuetable
, it shouldn't be any much different. Look at the what's changed for info on changes from version 1 and the upgrade guide on how you could upgrade from version 1.
Note on vue-resource version
vuetable internally uses vue-resource to request data from the api-url
. Prior to v1.5.3, vuetable uses vue-resource v0.7.4 and it retrieves the returned data from response.data
object. However, since v0.9.0 the response.data
has been renamed to response.body
. vuetable v1.5.3 onward has been updated to use vue-resource v1.0.2.
This will cause problem with vuetable to display no data because the expected object key is no longer existed and some other related problems as discussed in #100.
If you're using vue-resource in your project and the version is 0.9+, please upgrade to use vuetable v1.5.3.
Breaking Changes
v1.5.0
- deprecated props
detail-row-callback
: userow-detail-component
instead
v1.3.0
- deprecated props
paginateConfig
: usepaginateConfigCallback
insteaddetail-row
: usedetail-row-callback
instead
v1.2.0
-
sort-order
option type was changed fromObject
toArray
to supportmulti-sort
, therefore it should be declared as array. #36<vuetable //... :sort-order="[{ field: 'name', direction: 'asc' }]" ></vuetable>
##Live Demo
What is vuetable
?
vuetable
is a Vue.js component that will automatically request (JSON) data
from the server and display them nicely in html table with swappable/extensible
pagination sub-component. You can also add buttons to each row and hook an event
to it
Please note that all the examples show in here are styling using Semantic UI CSS Framework, but
vuetable
should be able to work with any CSS framwork including Twitter's Bootstrap. Please read through and see more info below.
You do this:
<div id="app" class="ui vertical stripe segment">
<div class="ui container">
<div id="content" class="ui basic segment">
<h3 class="ui header">List of Users</h3>
<vuetable
api-url="http://example.app:8000/api/users"
table-wrapper="#content"
:fields="columns"
:item-actions="itemActions"
></vuetable>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
columns: [
'name',
'nickname',
'email',
'birthdate',
'gender',
'__actions'
],
itemActions: [
{ name: 'view-item', label: '', icon: 'zoom icon', class: 'ui teal button' },
{ name: 'edit-item', label: '', icon: 'edit icon', class: 'ui orange button'},
{ name: 'delete-item', label: '', icon: 'delete icon', class: 'ui red button' }
]
},
methods: {
viewProfile: function(id) {
console.log('view profile with id:', id)
}
},
events: {
'vuetable:action': function(action, data) {
console.log('vuetable:action', action, data)
if (action == 'view-item') {
this.viewProfile(data.id)
}
},
'vuetable:load-error': function(response) {
console.log('Load Error: ', response)
}
}
})
</script>
And you get this!
Since I'm mainly using Semantic UI as my default CSS Framework, all the css
styles in vuetable
are based on Semantic UI. If you're using Twitter's Bootstrap
css framework, please see documentation in the Wiki pages.
Usage
Javascript
//vue-table dependencies (vue and vue-resource)
<script src="https://cdn.jsdelivr.net/vue/1.0.28/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.3.4/vue-resource.common.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/vue.table/1.5.3/vue-table.min.js"></script>
//or
<script type="text/javascript" src="http://cdn.jsdelivr.net/vue.table/1.5.3/vue-table.js"></script>
Bower
$ bower install vuetable
NPM
$ npm install vuetable
Vueify version for Browserify and Webpack
Just import
or require
like so,
//
// firstly, require or import vue and vue-resource
//
var Vue = require('vue');
var VueResource = require('vue-resource');
Vue.use(VueResource);
//
// secondly, require or import Vuetable and optional VuetablePagination component
//
import Vuetable from 'vuetable/src/components/Vuetable.vue';
import VuetablePagination from 'vuetable/src/components/VuetablePagination.vue';
import VuetablePaginationDropdown from 'vuetable/src/components/VuetablePaginationDropdown.vue';
//
// thirdly, register components to Vue
//
Vue.component('vuetable', Vuetable);
Vue.component('vuetable-pagination', VuetablePagination)
Vue.component('vuetable-pagination-dropdown', VuetablePaginationDropdown)
You can combine the second and third steps into one if you like.
You need to explicitly register the pagination components using Vue.component()
(instead of just declaring them through the components:
section); otherwise, the pagination component will not work or swappable or extensible. I guess this is because it is embedded inside vuetable
component.
Direct include
Just import the vue-table.js
after vue.js
and vue-resource.js
library in your page like so.
<script src="js/vue.js"></script>
<script src="js/vue-resource.js"></script>
<script src="js/vue-table.js"></script>
Then, reference the vuetable via <vuetable>
tag as following
<div id="app">
<vuetable
api-url="/api/users"
:fields="columns"
></vuetable>
</div>
<script>
new Vue({
el: '#app',
data: {
columns: [
'firstname',
'lastname',
'nickname',
'birthdate',
'group.name_en',
'gender',
'last_login',
'__actions'
]
}
})
</script>
api-url
is the url of the api thatvuetable
should request data from. The returned data must be in the form of JSON formatted with at least the number of fields defined infields
property.fields
is the fields mapping that will be used to display data in the table. You can provide only the name of the fields to be used. But if you would like to get the true power ofvuetable
, you must provide some more information. Please see Field Definition section for more detail.
For more detail, please see documentation in the Wiki pages.
Browser Compatability
As I use Chrome almost exclusively, it is gaurantee to work on this browser and it SHOULD also work for other WebKit based browsers as well. But I can't really gaurantee that since I don't use them regularly.
However, vuetable
will NOT WORK on Internet Explorer (even IE11) due to the use of <template>
tag inside <table>
according to this. In order to make it work with CSS framework table styling, I have to preserve the use of <table>
and <template>
tag inside it.
It seems to work just fine in Microsoft Edge though. Anyway, if you find that it does not work on any other browser, you can let me know by posting in the Issues. Or if you are able to make it work on those browser, please let me know or create a pull request.
Contributions
Any contribution to the code (via pull request would be nice) or any part of the documentation (the Wiki always need some love and care) and any idea and/or suggestion are very welcome.
However, please do not feel bad if your pull requests or contributions do not get merged or implemented into vuetable
.
Your contributions can, not only help make vuetable
better, but also push it away from what I intend to use it for. I just hope that you find it useful for your use or learn something useful from its source code. But remember, you can always fork it to make it work the way you want.
Building
Run npm install
Then make sure, you have installed browserify:
# npm install browserify -g
You might need root access for running the above command.
Then you can simply run the build script included in the root folder:
$ ./build.sh
This will compile the vue components in the src
directory to one file in the dist
folder.
You might want to get a minified version, in this case run this:
$ ./build.sh production
For developement it's useful when it's not needed to recompile manually each time you make a change. If you want this convenience first install watchify globally:
# npm install watchify -g
then run
$ ./build.sh watch
Now each time you make a change, the source will be recompiled automatically.
License
vuetable
is open-sourced software licensed under the MIT license.
Top Related Projects
Vue.js 2 grid components
An easy to use powerful data table for vuejs with advanced customizations including sorting, column filtering, pagination, grouping etc
A powerful data table based on vuejs. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.
A simple, customizable and pageable table with SSR support, based on vue2 and element-ui
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot