This is a vue project that houses a reusable vue data table component. This project was created using vue cli.
The Data Table component can be found in the components folder as DataTable.vue and it can be extracted and used in any other vue project. I plan to deploy the component as an npm module soon.
- Search through any column
- Sortable columns
- Editable cells
- Regex search pattern
- Custom style classes for table
https://vue-data-table.netlify.com
The component expects the following variables
dataSource, // Table data as an array of objects
columns, // columns to display as an array of objects
// Each column should be in this format
{
title: '**',
dataIndex: '**',
editable: true, (optional)
sortable: true, (optional)
type: 'Date' (optional) //pass date for proper date display
}
config: {
total, // pass number for server-side pagination
itemsPerPage, // defaults to 10
frontPagination: true, //pass false for server-side pagination
tableClass, (optional)
thClass, (optional)
tdClass, (optional)
hasSearch (optional) // pass for omnisearch functionality
}
<DataTable @cell-change="handleCellChange" :dataSource="dataSourceVariable" :columns="columnsVariable" :config="configVariable" />
Listen for cell change with the cell-change
event. It returns data in this format
{
row, //changed row
cell //changed cell property
}
Listen for page change with the page-change
event. It emits the current page
npm install
npm run serve
npm run build
npm run test
npm run lint
npm run test:unit