Troubleshooting Primevue Data table styling issues in Vue3

Currently, I am attempting to incorporate grids into my data table using primevue library. However, despite following the provided example at https://www.primefaces.org/primevue/datatable/dynamiccolumns, the gridlines are not appearing on the table.

The code snippet is as follows:

<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>

In addition, here's the script tag content:

<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>

After running the code, only the plain table appears without any gridlines: https://i.sstatic.net/8pLPz.png Any assistance on identifying what might be wrong would be highly appreciated.

Answer №1

Ensure that you have imported the necessary PrimeVue CSS files

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

You can select any theme from the documentation, but choosing one is a must

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using asynchronous import statements in Vue allows for more efficient loading of components

I am using Vue and have a method in my file called load.js. async function loadTask(x) { return await x; // Some async code } export { loadTask }; In one of my Vue components, I call the method but encounter an issue where the use of await prevents the ...

Encountering problems with Nuxt/Vue hydration when utilizing a slotted component

Recently, in my new Nuxt project, I have been facing some peculiar hydration problems. Despite putting effort into isolating the issue and providing a demonstration (refer to the image), the hydration error seems to occur unpredictably. Is there anyone ou ...

vue rich text editor with syncfusion image upload functionality

Is there a way to upload an image into my vuex action and retrieve the image value? I'm facing issues with loading it through vuex. Can I download images via vuex as well? Take a look at the screenshots below. View Image View Image View Image <tem ...

generating declaration files for components with accurate type definitions from propTypes

I am in the process of creating a react/js library using rollup. My approach involves utilizing typescript to generate declaration files for my components. Despite having propTypes defined for my components, I have noticed that the emitted .d.ts files as ...

Using Vuejs v-for for infinite scrolling has been causing significant lag issues

I've encountered a strange Vue.js effect where every time I add a new object data, the v-for re-renders all objects even if they're already rendered. Currently, I'm trying to implement an infinite scroll feature similar to Facebook's. ...

Exploring Typescript keyof in Storybook's User Interface customizations

Currently, I am working on developing components for integration with Storybook, but I am encountering an issue related to Typescript inferred types. While striving for code reusability, I prefer not to specify the options for a control within the story i ...

Execute a function (with arguments) within a v-for loop in Vue.js

Currently, I am attempting to create a select element using Vue.js and Material Design that has 2 levels: categories and items. Each category can contain multiple items which may be selected or not. <md-select v-if="categories.length > 0" name="cate ...

Exploring the dynamic duo of Github and vue.js

As I am new to programming and currently learning JavaScript and Vue.js, I have been trying to deploy my first Vue.js app without success. Despite spending hours on it, I still cannot figure it out and need to seek assistance. Every time I try to deploy, ...

Unable to figure out a method to properly synchronize a vue.js asynchronous function

I am facing an issue with my code where everything works fine if I uncomment the "return" statement in fetchData. How can I make sure that I wait for the completion of this.fetchData before populating the items array? I have tried using promises, async/awa ...

Efficiently convert Map keys into a Set in Javascript without the need to copy and rebuild the set

Even though I am capable of const set = new Set(map.keys()) I don't want to have to rebuild the set. Additionally, I prefer not to create a duplicate set for the return value. The function responsible for returning this set should also have the abili ...

Vuetify Upload Files

Recently, I implemented a form containing the Vuetify component v-file-input: <v-file-input chips multiple label="File(s)" v-model="file.files"></v-file-input> The structure of my data object is as follows: data: () => ({ file: { ...

Instructions for rendering a component after directly inserting its tag as raw HTML in Vue 3

Recently, I encountered an issue with a vue instance that contains a globally registered component in a legacy project. Due to the legacy nature of the project, it heavily relies on jsrender for rendering html post ajax requests. Despite having the compon ...

Cannot locate: Unable to find the module '@react-stately/collections' in the Next.js application

While working on my Next.js app, I decided to add the react-use package. However, this led to a sudden influx of errors in my Next.js project! https://i.stack.imgur.com/yiW2m.png After researching similar issues on Stackoverflow, some suggestions include ...

How can I access the value of an HTML attribute using a v-on:click event within an anchor tag in Vue.js?

In my Vue.js and Laravel app, I am trying to access the value of the 'h5' attribute which is {{$subcategory->name}}. This will allow me to perform additional actions within my application. <div class="container" id = "showProd"> < ...

Issue with implicitly assigning 'any' type to overloaded variadic generic function

We have some code snippets for you to review: export type actions = { abort: () => void; back: () => void; next: () => void; resume: () => void; }; class Sabar { public use<T1>(fn: (arg1: T1, ctx: object, actions: actions) =&g ...

Storing data from multiple children and triggering a parent component function in Vue: A guide

In my Messaging Tool component, I have several child components that make up the messaging tool interface. You can see the visual representation of these components here: https://i.stack.imgur.com/JoEko.png There are 3 channels within the tool, each openi ...

Bidirectional data binding in components within other components

I'm currently facing a challenge with reusing my components. My goal is to pass the data from one component as a prop to another component, but Vue throws an error regarding prop mutation. For example, I have contacts that need to be displayed in mu ...

When assigning JSON to a class object, the local functions within the class became damaged

This is a demonstration of Object Oriented Programming in JavaScript where we have a parent Class called Book with a child class named PriceDetails. export class Book { name: String; author: String; series: String; priceDetails: Array<Price> ...

Vue.js HTML5 Editor_vueful

I am currently utilizing browserify and attempting to incorporate the vue-html5-editor library from https://github.com/PeakTai/vue-html5-editor. However, when I attempt the following code: Vue.use(require('vue-html5-editor')); An error is thro ...

How to initiate a refresh in a React.js component?

I created a basic todo app using React, TypeScript, and Node. Below is the main component: import * as React from "react" import {forwardRef, useCallback, useEffect} from "react" import {ITodo} from "../types/type.todo" import ...