2

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 enter image description here I will be very grateful if someone could let me know what am I doing incorrectly?

1 Answer 1

0

Make sure you're importing the PrimeVue CSS dependencies

primevue/resources/themes/saga-blue/theme.css       //theme
primevue/resources/primevue.min.css                 //core css
primeicons/primeicons.css                           //icons

you're free to choose any theme, they're listed in the docs, but picking one is required

Sign up to request clarification or add additional context in comments.

4 Comments

Yes I am importing them as well, it's still not working
same here ... I imported them all ... I got the components and icons .. but classes are not applied ... when checked the primevue.min.css it says /** * The primevue[.min].css has been deprecated. In order not to break existing projects, it is currently included in the build as an empty file. */ ... could that be the issue?
The question and answer are both outdated. Always follow the latest instructions in the documentation. As of today, you only need the theme CSS import
tbh @yoduh the documentation is a bit misleading.. check the video tutorial at the bottom of the page ... they specifically mention (check the 4:33) the primevue.min.css ... however, your reply here worked well :) linking it here for the others too stackoverflow.com/questions/77614800/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.