Initiated DataTable
parent
750f74d8c0
commit
1b598bd2ec
|
@ -55,6 +55,7 @@
|
||||||
<transition name="layout-submenu-wrapper">
|
<transition name="layout-submenu-wrapper">
|
||||||
<div v-show="activeMenuIndex === 2">
|
<div v-show="activeMenuIndex === 2">
|
||||||
<div>
|
<div>
|
||||||
|
<router-link to="/datatable">● DataTable</router-link>
|
||||||
<router-link to="/dataview">● DataView</router-link>
|
<router-link to="/dataview">● DataView</router-link>
|
||||||
<router-link to="/fullcalendar">● FullCalendar</router-link>
|
<router-link to="/fullcalendar">● FullCalendar</router-link>
|
||||||
<router-link to="/paginator">● Paginator</router-link>
|
<router-link to="/paginator">● Paginator</router-link>
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
columnKey: {
|
||||||
|
type: Object,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
field: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
sortField: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
sortable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
type: null,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
type: null,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,262 @@
|
||||||
|
<template>
|
||||||
|
<div class="p-datatable p-component">
|
||||||
|
<slot></slot>
|
||||||
|
<div class="p-datatable-wrapper">
|
||||||
|
<table>
|
||||||
|
<thead class="p-datatable-thead">
|
||||||
|
<tr>
|
||||||
|
<th v-for="col of columns" :key="col.columnKey||col.field">
|
||||||
|
<span class="p-column-title" v-if="col.header">{{col.header}}</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="p-datatable-tbody">
|
||||||
|
<tr class="p-datatable-row" v-for="(rowData, index) of value" :key="getRowKey(rowData, index)">
|
||||||
|
<td v-for="col of columns" :key="col.columnKey||col.field">
|
||||||
|
{{resolveFieldData(rowData, col.field)}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ObjectUtils from '../utils/ObjectUtils';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Array,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
dataKey: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
columns: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.columns = this.$children;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getRowKey(rowData, index) {
|
||||||
|
return this.dataKey ? ObjectUtils.resolveFieldData(rowData, this.dataKey): index;
|
||||||
|
},
|
||||||
|
resolveFieldData(rowData, field) {
|
||||||
|
return ObjectUtils.resolveFieldData(rowData, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.p-datatable {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-datatable-thead > tr > th,
|
||||||
|
.p-datatable .p-datatable-tbody > tr > td,
|
||||||
|
.p-datatable .p-datatable-tfoot > tr > td {
|
||||||
|
padding: .25em .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-sortable-column {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-sortable-column-icon {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-auto-layout > .p-datatable-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-auto-layout > .p-datatable-wrapper > table {
|
||||||
|
table-layout: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sections */
|
||||||
|
.p-datatable-header,
|
||||||
|
.p-datatable-footer {
|
||||||
|
padding: .25em .5em;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-header {
|
||||||
|
border-bottom: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-footer {
|
||||||
|
border-top: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Paginator */
|
||||||
|
.p-datatable .p-paginator-top {
|
||||||
|
border-bottom: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-paginator-bottom {
|
||||||
|
border-top: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollable */
|
||||||
|
.p-datatable-scrollable-wrapper {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.p-datatable-scrollable-header,
|
||||||
|
.p-datatable-scrollable-footer {
|
||||||
|
overflow: hidden;
|
||||||
|
border: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-scrollable-body {
|
||||||
|
overflow: auto;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-scrollable-body > table > .p-datatable-tbody > tr:first-child > td {
|
||||||
|
border-top: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-virtual-table {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Frozen Columns */
|
||||||
|
.p-datatable-frozen-view .p-datatable-scrollable-body {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-frozen-view > .p-datatable-scrollable-body > table > .p-datatable-tbody > tr > td:last-child {
|
||||||
|
border-right: 0 none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-unfrozen-view {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Filter */
|
||||||
|
.p-column-filter {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Resizable */
|
||||||
|
.p-datatable-resizable > .p-datatable-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-resizable .p-datatable-thead > tr > th,
|
||||||
|
.p-datatable-resizable .p-datatable-tfoot > tr > td,
|
||||||
|
.p-datatable-resizable .p-datatable-tbody > tr > td {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-resizable .p-resizable-column {
|
||||||
|
background-clip: padding-box;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-resizable-fit .p-resizable-column:last-child .p-column-resizer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-column-resizer {
|
||||||
|
display: block;
|
||||||
|
position: absolute !important;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: .5em;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0px;
|
||||||
|
cursor:col-resize;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-column-resizer-helper {
|
||||||
|
width: 1px;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 10;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Edit */
|
||||||
|
.p-datatable .p-datatable-tbody > tr > td.p-cell-editing .p-component {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reorder */
|
||||||
|
.p-datatable-reorder-indicator-up,
|
||||||
|
.p-datatable-reorder-indicator-down {
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
.p-datatable-responsive .p-datatable-tbody > tr > td .p-column-title {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 40em) {
|
||||||
|
.p-datatable-responsive .p-datatable-thead > tr > th,
|
||||||
|
.p-datatable-responsive .p-datatable-tfoot > tr > td {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-responsive .p-datatable-tbody > tr > td {
|
||||||
|
text-align: left;
|
||||||
|
display: block;
|
||||||
|
border: 0 none;
|
||||||
|
width: 100% !important;
|
||||||
|
float: left;
|
||||||
|
clear: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-responsive .p-datatable-tbody > tr > td .p-column-title {
|
||||||
|
padding: .4em;
|
||||||
|
min-width: 30%;
|
||||||
|
display: inline-block;
|
||||||
|
margin: -.4em 1em -.4em -.4em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loader */
|
||||||
|
.p-datatable-loading-overlay {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)";
|
||||||
|
opacity: 0.1;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable-loading-content {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
z-index: 2;
|
||||||
|
margin-top: -1em;
|
||||||
|
margin-left: -1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p-datatable .p-datatable-loading-icon {
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -10,6 +10,8 @@ import Card from './components/card/Card';
|
||||||
import Chart from './components/chart/Chart';
|
import Chart from './components/chart/Chart';
|
||||||
import Checkbox from './components/checkbox/Checkbox';
|
import Checkbox from './components/checkbox/Checkbox';
|
||||||
import Chips from './components/chips/Chips';
|
import Chips from './components/chips/Chips';
|
||||||
|
import Column from './components/column/Column';
|
||||||
|
import DataTable from './components/datatable/DataTable';
|
||||||
import DataView from './components/dataview/DataView';
|
import DataView from './components/dataview/DataView';
|
||||||
import DataViewLayoutOptions from './components/dataviewlayoutoptions/DataViewLayoutOptions';
|
import DataViewLayoutOptions from './components/dataviewlayoutoptions/DataViewLayoutOptions';
|
||||||
import Dialog from './components/dialog/Dialog';
|
import Dialog from './components/dialog/Dialog';
|
||||||
|
@ -69,6 +71,8 @@ Vue.component('Card', Card);
|
||||||
Vue.component('Chart', Chart);
|
Vue.component('Chart', Chart);
|
||||||
Vue.component('Checkbox', Checkbox);
|
Vue.component('Checkbox', Checkbox);
|
||||||
Vue.component('Chips', Chips);
|
Vue.component('Chips', Chips);
|
||||||
|
Vue.component('Column', Column);
|
||||||
|
Vue.component('DataTable', DataTable);
|
||||||
Vue.component('DataView', DataView);
|
Vue.component('DataView', DataView);
|
||||||
Vue.component('DataViewLayoutOptions', DataViewLayoutOptions);
|
Vue.component('DataViewLayoutOptions', DataViewLayoutOptions);
|
||||||
Vue.component('Dialog', Dialog);
|
Vue.component('Dialog', Dialog);
|
||||||
|
|
|
@ -105,6 +105,11 @@ export default new Router({
|
||||||
path: '/chips',
|
path: '/chips',
|
||||||
name: 'chips',
|
name: 'chips',
|
||||||
component: () => import('./views/chips/ChipsDemo.vue')
|
component: () => import('./views/chips/ChipsDemo.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/datatable',
|
||||||
|
name: 'datatable',
|
||||||
|
component: () => import('./views/datatable/DataTableDemo.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/dataview',
|
path: '/dataview',
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="content-section introduction">
|
||||||
|
<div class="feature-intro">
|
||||||
|
<h1>DataTable</h1>
|
||||||
|
<p>DataTable displays data in tabular format.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-section implementation">
|
||||||
|
<h3 class="first">Basic</h3>
|
||||||
|
<DataTable :value="cars">
|
||||||
|
<Column field="vin" header="Vin"></Column>
|
||||||
|
<Column field="year" header="Year"></Column>
|
||||||
|
<Column field="brand" header="Brand"></Column>
|
||||||
|
<Column field="color" header="Color"></Column>
|
||||||
|
</DataTable>
|
||||||
|
|
||||||
|
<h3>Dynamic Columns</h3>
|
||||||
|
<DataTable :value="cars">
|
||||||
|
<Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field"></Column>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DataTableDoc />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CarService from '../../service/CarService';
|
||||||
|
import DataTableDoc from './DataTableDoc';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
columns: null,
|
||||||
|
cars: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
carService: null,
|
||||||
|
created() {
|
||||||
|
this.carService = new CarService();
|
||||||
|
|
||||||
|
this.columns = [
|
||||||
|
{field: 'vin', header: 'Vin'},
|
||||||
|
{field: 'year', header: 'Year'},
|
||||||
|
{field: 'brand', header: 'Brand'},
|
||||||
|
{field: 'color', header: 'Color'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.carService.getCarsSmall().then(data => this.cars = data);
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
'DataTableDoc': DataTableDoc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
|
||||||
|
</style>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<template>
|
||||||
|
<div class="content-section documentation">
|
||||||
|
<TabView>
|
||||||
|
<TabPanel header="Documentation">
|
||||||
|
<h3>Import</h3>
|
||||||
|
<CodeHighlight lang="javascript">
|
||||||
|
import DataTable from 'primevue/datatable';
|
||||||
|
</CodeHighlight>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</div>
|
||||||
|
</template>
|
Loading…
Reference in New Issue