So I am trying to add grids to my data table using primevue. But for some reason the table is bot showing grids. I am following the example given here https://www.primefaces.org/primevue/datatable/dynamiccolumns.
My code is:
<template>
<div class="tableView">
<DataTable :value="data" showGridlines responsiveLayout="scroll" >
<Column v-for="col in columns" :field="col.field" :header="col.header" :key="col.field"></Column>
</DataTable>
<el-button type="warning" round @click="togtab">Toggle-Table</el-button>
</div>
and script tag is as follows:
<script>
import DataTable from '../../node_modules/primevue/datatable';
import Column from '../../node_modules/primevue/column';
import ColumnGroup from '../../node_modules/primevue/columngroup';
import Row from '../../node_modules/primevue/row';
export default {
name: 'TableComp',
props:['data'],
data() {
return {
columns:[]
};
},
components: {
DataTable,
Column
},
methods: {
togtab(){
for (let i=0; i< Object.keys(this.data).length ;i++ ){
this.columns[i] = {field: Object.keys(this.data[0])[i], header: Object.keys(this.data[0])[i]}
}
console.log(this.columns)
}
}
}
</script>
In the output I can see just the table
I will be very grateful if someone could let me know what am I doing incorrectly?