Zhi Xiong introduced Vue-table-dynamic which is a vue component of a dynamic table. It’s designed to respond to data changes in real-time and is oriented to the runtime. It has many customizable options and is very easy to use. It has many features like sorting, filtering, editing, pagination, multiple selections, etc.
Features
- Multiple Select
- Search
- Sort
- Filter
- Pagination
- Edit
- Border
- Stripe
- Highlight
- Column Width
- Configure Header
- Fixed Header
- Fixed Columns
- Slot
Installation
npm install vue-table-dynamic --save
Usage
You can install this package via Npm, Just run this command.
import VueTableDynamic from 'vue-table-dynamic'
Registration
Global registration
Vue.use(VueTableDynamic)
Local registration
<script>
export default {
components: { VueTableDynamic }
}
</script>
Basic Table
<template>
<div class="base-demo" style="width: 400px">
<vue-table-dynamic :params="params"></vue-table-dynamic>
</div>
</template>
<script>
import VueTableDynamic from 'vue-table-dynamic'
export default {
name: 'Demo',
data() {
return {
params: {
data: [
['Cell-1', 'Cell-2', 'Cell-3'],
['Cell-4', 'Cell-5', 'Cell-6'],
['Cell-7', 'Cell-8', 'Cell-9']
]
}
}
},
components: { VueTableDynamic }
}
</script>
Border
Bordered table usage
border:truewith borderborder:falsewithout border
Stripe
Striped rows
stripe:truestripedstripe:falseunstriped
Highlight
Highlighted rows/columns/cells
highlight:{row?:Arrayconfigure highlighted rows, columns, cells. such as:; column?:Array ; cell?:Array<[number,number]>;} {row: [1], column: [1], cell: [[-1, -1]]}if negative, the position from the end of the array.highlightedColor:stringconfigure highlighted colors
Multiple Select
Select multiple rows
showCheck:booleanshow checkbox of rowsgetCheckedRowDatas:functionget data for all currently selected rowssetAllRowChecked:function(selected:boolean)toggle all selectionselect:eventcurrently selected/unselected rows
Search
Filter rows by keyword
enableSearch:booleanenable/disable searchingsearch:function(value:string, included:array, excluded:array)manual row filtering
Sort
Sort rows based on specified column data
sort:Arrayarray members are sortable column indexes. such as:[0, 1]
Filter
Filter rows based on specified column data and rule
filter:Array<{column:number; content:Array<{text:string; value:string|number;}>; method:function;}>specify filterable columns and rules. such as:[{column: 0, content: [{text: ‘> 2’, value: 2}], method: (value, cell) => { return cell.data > value }}]filter[].column:column indexfilter[].content:filter itemsfilter[].method:filter rule.
Pagination
Table with pagination
pagination:booleanenable/disable paginationpageSize?:numberrow count of each page. default: 10pageSizes?:Arrayoptions of row count per page. default: -[10, 20, 50, 100]
Edit
Editable table
Support specifying rows/columns/cells for editing
edit:{row?:Arrayconfigure editable rows, columns, cells. such as:; column?:Array ; cell?:Array<[number,number]>;} {row: [1], column: [1], cell: [[-1, -1]]}. if negative, the position from the end of the array.getData:function()table data changed after editing, get the latest data by this method.cell-change:eventcell data changed eventedit:{row: ‘all’}all cells can be edited- if
headeris‘row’, the first row is not editable - if the type of source data item is
number, only acceptable when entering numbers
This package has a lot more features with many code examples. If you want to learn more about this package you can visit its detailed documentation on Github.