import component in vue file
import DataTable from '@/components/DataTable/DataTable.vue';
define component in script section
components: {
DataTable
}
define component props in data function
data: function () {
return {
filePath: 'path/to/file',
fileLocation: 'remote',
// columns passed to component
columns: [
{
name: 'Name',
sort: true,
edit: true,
type: 'string'
},
{
name: 'Date',
sort: false,
edit: false,
type: 'date'
}
]
}
}
options for column property
-
name: stringname of column -
sort: booleanwill set column to sortable -
edit: booleanwill set column vale editable -
type: stringonly type 'date' is available. setting this type will filter column value as Date
In Template section of vue file, add tag like this:
<template>
<div>
<DataTable
title="Payment Data"
:file="filePath"
:file-location="fileLocation"
:columns='columns'
/>
</div>
</template>
attributes for DataTable
-
title:stringtile to appear on top of table -
file:stringfile path to load from -
file-location:stringvalue are 'remote' or 'local', only remote will work now -
columns:objectcolumns properties/options
project is created using vue-cli. install vue-cli.
npm install -g @vue/cli
run vue-cli GUI by
vue ui
through this GUI load project and manage dependies, run tasks like serve build test. This is an easy and recomended way.
or
through command line
npm install
npm run serve
npm run build
npm run test
npm run lint
npm run test:e2e
npm run test:unit
1st build the project through vue-cli GUI or through command line
npm run build
this will place all build files in /dist folder at root of the project. Copy all files and folders to deployment server. index.html file is included so accessing server will run the project in browser.
- for editing, different input types can be used based on column types. e.g select, dates, textarea
- paging could be added