Issue with fixed header in Vuetify v-data-table not functional

While working with the Vuetify v-data-table component, I have enabled the fixed-header property. However, I have noticed that the table header is scrolling along with the table body. I am using the latest version of Chrome. Does anyone know how to address this issue and make it work correctly?

Answer №1

Make sure to include the height attribute when using this code snippet. You can even set the height to "100%" and it will still function properly.

<v-data-table
      height="400"
      v-model="selected"
      :headers="headers"
      fixed-header
      :items="desserts"
      item-key="name"
    >
</v-data-table>

https://codepen.io/ellisdod/pen/gOpzBmQ

Answer №2

In my experience, using height="100%" did not yield the desired results. I also couldn't set the height in pixels because I needed the table to fill the entire page height. As a solution, I opted for height="100vh".

<v-data-table
    :headers="headers"
    :items="items"
    disable-pagination
    fixed-header
    hide-default-footer
    dark
    height="100vh">
</v-data-table>

Answer №3

If you're looking for a solution that doesn't require a fixed height and allows your table to fill all available space, try using flexbox. Set flex-grow: 1; overflow: hidden; on the container and apply a class to the table with display: flex; flex-grow: 1;

Check out this codepen demo for reference: https://codepen.io/esquilax76/pen/gOoGyPb

I hope this solution works for you!

Answer №4

After some searching, I came across a solution that involves calculating the pixels of the elements above the v-data-table. In my particular case, it was the header that needed to be accounted for. By subtracting this value from 100vh, we arrive at something like calc(100vh - 245px).

<v-data-table
   :headers="headers"
   :items="orders"
   :loading="isLoading"
   fixed-header
   height="calc(100vh - 245px)"
>

Answer №5

This particular method has been very effective for me. It utilizes a section that is incredibly user-friendly and efficient to work with.

    <section class="view">
      <v-card class="card-top">
        Header
      </v-card>
      <v-card class="table-container">
        <v-data-table
          :headers="headers"
          :items="desserts"
          fixed-header
          hide-default-footer
          disable-pagination
          class="flex-table"
        />
      </v-card>
    </section>

https://codepen.io/esquilax76/pen/gOoGyPb

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

My attempts to use media queries are being ignored by Internet Explorer

While other browsers recognize and function properly, it seems like IE is not recognizing my media queries. Could there be something wrong with my code? I've created a similar design before without any issues, so why is this one causing problems? Her ...

Transitioning the Background Image is a common design technique

After spending hours trying to figure out how to make my background "jumbotron" change images smoothly with a transition, I am still stuck. I have tried both internal scripts and JavaScript, but nothing seems to work. Is there any way to achieve this witho ...

Exploring Vue's data binding with both familiar and mysterious input values

How can I model an object in Vue that contains both known and unknown values? The quantity is unknown, but the type is known. I need to present user inputs for each type, where the user enters the quantity. How should I approach this? data() { retur ...

Encountering a 401 error when making an Axios request for data in a Laravel application

I have been working on fetching reports using axios in Laravel. Everything runs smoothly when tested with Postman, but I encountered error 401 here. Here is the code snippet: #Reports.vue file <template> <div> <h1>All reports ...

Design a circular text element using Tailwind CSS

Just starting out as a web developer and running into some issues with Tailwind CSS. Here's what I'm trying to achieve: https://ibb.co/KL8cDR2 This is the code I have right now: <div class="w-1/2 h-10 rounded-full bg-gray-400" style ...

Retrieving locale messages by accessing the app context from customized .js files

Currently, I am developing a Vue.js application with Nuxt.js in SSR mode. The project includes plugins such as axios and vue-i18n. nuxt.config.js : export default { mode: 'universal', // additional configurations modules: [ '@nuxt ...

Various CSS libraries offer a range of design options, including DataTables and Bootstrap

Incorporating both Bootstrap and DataTable into my design has caused conflicts with CSS styles. This issue extends beyond just these libraries, making me wonder if there is a way to prioritize my own styles over library styles. Can anyone provide guidanc ...

Combine the text of the button onto a single line

It seems like my button text appears fine on Safari, but in Google Chrome the issue arises. When you first arrive at the button, everything looks okay. However, after navigating through more posts and encountering the load more button again, the text gets ...

Creating a PHP Class for Converting CSS3 Rules to Ensure Compatibility Across Different Browsers

Seeking assistance with developing a class that can process a style sheet, identify browser-specific CSS3 rules, and provide compatibility for all browsers. The goal is to simplify the process of writing styles for one browser and then generating CSS files ...

Having trouble compiling your Vue project and running into the "No mixed spaces and tabs" error?

Below are the details with an error: Error Details: Failed to compile. ./src/components/Header.vue Module Error (from ./node_modules/eslint-loader/index.js): H:\project\VueProjects\stock-trader\src\components\Header.vue 27: ...

In vue3, transitions smoothly slide in but do not slide out

I have a code snippet Here is the parent component: <template> <div> <button @click="cartToggle">Toggle</button> </div> <div> <Child :visible="cartVisible" @update:visibl ...

Adding a dynamic index from ngFor to an HTML attribute value can be accomplished by incorporating the current

I am using ngFor and I am trying to make an attribute inside the loop change its value by adding the ngFor index. This means that each div created within ngFor will have a unique attribute value. Source: <div class="class1" *ngFor="let item of items; l ...

Tips for showcasing boxed numerical characters on a website

Currently, I am tackling a project that involves converting a PDF into HTML. The original .ai file shows some numeric characters inside a box: Even though I am aware that the font used in the file is GothicMB101Pro DeBold-83pv-RKSJ-H, unfortunately, I do ...

Encountering an error while trying to load a CSS file in a React project using webpack due

I'm currently working on a React project that utilizes styled components, and I've been attempting to integrate a CSS file as part of the react-image-gallery package. Following the instructions provided, I included the css-loader and style-loade ...

Setting text alignment in Bootstrap based on breakpoints

Imagine this code: import React from 'react' import DarkPattern from '../Assets/dark-pattern.jpg' const Profile = () => { return ( <div> <section className="bg-dark text-light text-center " ...

Aligning thumbnail images in a jQuery Mobile listview

Hey, I recently added a list view that includes thumbnails. I used the following code: <ul data-role="listview" data-inset="false" data-theme="a" data-dividertheme="d> <li><a href="image.php?imgid=2"> <img src="../images/comma. ...

Enhance the appearance of the circular heading

Is there anyway to customize the look of this rounded header? I am having trouble setting a white background. Update #1: This is my current header HTML code: Here is how it currently appears: I utilized Bootstrap along with some custom CSS. Update #2: ...

Display or conceal <ul>'s using JavaScript when the mouse enters or leaves

I'm encountering an issue with a basic JavaScript function. The goal is to toggle the dropdown menu on my website when the mouse hovers over or leaves the menu. The problem arises because my script is triggered by the ul tags within my menu, and I ha ...

Accessing Google authentication: A guide to programmatically prompting user consent and retrieving the CredentialResponse after successful login

Is there a way to trigger the Prompt for User Consent to open when clicking a custom HTML button instead of the Login iframe button rendered by Google? I am utilizing the Sign In With Google JavaScript API, and while I couldn't find a function to achi ...

[VUE ALERT]: Issue found in mounted hook: "The variable this.$refs.canvas is not defined."

I have integrated Vue Chart into one of my projects, but I am encountering an error. Here is the code for the Chart Component: <line-example></line-example> And below is my script: <script> import Navbar from '@/components/navb ...