Freeze the headers of multiple tabulators on a single page without restricting the height

My website contains more than 3 tabs and several charts interspersed between tables.

Based on the requirement, we have not set a fixed size for the tables. Therefore, the height of the table varies depending on the data.

I am looking to fix the headers of the tables in the user interface so that when scrolling vertically, the header remains fixed while only the data scrolls.

var tabledata = [
    // Data content here
];

// Initialize table
var table1 = new Tabulator("#tblData1", {
    // Table configuration for tblData1
});

var table2 = new Tabulator("#tblData2", {
    // Table configuration for tblData2
});
<html>
<head>
<script src="js/tabulator.min.js"></script>
<link href="css/tabulator.min.css" rel="stylesheet"/>
</head>
<body>
<div id="tblData1" style="width:550px;"></div>
<br><br><br><br>
<div id="tblData2" style="width:550px;"></div>
<script type="text/javascript">
</script>
</body>
</html>

For a similar example, refer to: https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html

Answer №1

To achieve the desired outcome, it is essential to specify a maximum height for the table. Without this specification, the table will attempt to display all data without any scroll bar.

Without setting either a height or maxHeight, the table will expand to its full height, causing any scrolling to occur on the parent element or page body, resulting in the header moving along with the table.

The height or maxHeight can be defined using any valid CSS height value.

var table = new Tabulator("#example-table", {
    maxHeight:"100%", //ensure table does not exceed parent element's height
});

For more details, refer to the Layout Documentation

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

What is the method for adjusting the input text color in a textarea to green?

Is there a way to change the input color for this textarea so I can type green text on a black background? textarea{ background-color: black; } <textarea id="htmlCode" class="1111" placeholder="HTML"></textarea> ...

The cookie generated through jQuery(view) cannot be retrieved in PHP(controller) on the initial try

I've encountered a strange issue with Chrome and Firefox, surprisingly it works fine on IE occasionally. [Edit1: Problem occurs intermittently with IE as well] Premise: On my homepageView.php, I utilize jQuery to create a cookie, which I'll re ...

Adding Google Map V3 markers dynamically through jQuery

I have been using jquery and the Google Maps V3 API to dynamically add markers to my Google Maps. Whenever I click on the button search_button, an AJAX request is sent to the server, which returns a JSON array of LatLng values corresponding to the results. ...

Elements in Bootstrap Container class failing to align properly

Hello Everyone, I am attempting to achieve the same layout as demonstrated in [original image] where the "browse collection" div and the "request brochure" div are aligned with the four items above them. My approach involves using Bootstrap, and I assume ...

Should the header include individual CSS and JS files, or should all code be contained within a single CSS and JS file?

As I work on optimizing my website, I find myself juggling multiple plugins that include jQuery plugins with CSS along with my own JavaScript code. Currently, the CSS is spread across separate files for each plugin I have downloaded. When needed on a page ...

Deciphering the occurrence of jQuery-Mobile page firing events: the mystery behind dialog pages appearing upon closure

I'm still fairly new to jQuery-Mobile and I'm trying to wrap my head around what exactly happens when a page or dialog is loaded. To help illustrate the confusion I'm experiencing, I put together a small collection of files that showcase th ...

What is the best way to incorporate a text box along with a submit button that triggers a callback to a javascript function when clicked, utilizing either plain javascript or jQuery?

As a beginner in the world of JavaScript, I'm struggling to find the solution to this problem. Any assistance would be greatly welcomed. ...

How can I remove the gaps between Bootstrap panels on a website?

The Issue https://i.stack.imgur.com/I5EFR.png My problem is with the spacing between the panels, highlighted in red. I've attempted to remove them by using the following CSS: .panel { margin-top: 0; margin-bottom: 0; padding-top: 0; ...

How should errors from JavaScript (jQuery) be best showcased in ASP.NET MVC 3 views?

After sending a form to my ASP.NET MVC 3 server using a JavaScript handler with jQuery, I am receiving error responses in another JavaScript handler. My question is how should I go about displaying these error messages on the view? Ideally, I would like to ...

What could be causing the FontAwesome social icons in <ul> to malfunction?

I'm a beginner and I've been following various tutorials to achieve my goal. The main objective is to create animated social icons in the footer. However, I have encountered an issue where the social icons from FontAwesome are not working. When ...

Dynamic Height in React Material-UI Table with Sticky Headers and Multiple Rows

Currently, I am working with React and Material-UI to create a table that needs to have a sticky header for a multi-row table head. The challenge I'm facing is that I don't want to specify a fixed height for the table, but instead have all lines ...

Importing XML data into a JavaScript variable using jQuery without displaying an alert message

Despite previously asking questions about loading XML into a JS variable, I haven't found a satisfactory solution. In my script, I declare a variable before making an ajax request and then assign the result to that variable. However, this only seems t ...

"Choosing a div element using nth-child() method: a step-by-step guide

An HTML structure was provided which includes a section with an id of "main-content" and a class of "photo-grid". Inside this section are multiple div elements with a class of "col-1-4", each containing a link, paragraph, and image. <section id="main-c ...

Utilizing border-image property to showcase four dots in each corner of my div container

I'm having trouble applying a gradient color to my border using the border-image property. When I use border-image: linear-gradient(-180deg, #2D6BD0 0%, #83B8FF 100%);, I'm only seeing a single dot in each corner of my DIV. Does anyone know why t ...

The jquery .scroll function is not functioning properly, although the click function is working

Usually, I find working with the .scroll function to be quite straightforward. However, in this particular case, I'm encountering an issue and can't seem to figure out what could be wrong. The code snippet below is functioning as expected: $(w ...

Searching in Django utilizing jQuery keyup

When implementing a search functionality using the jQuery keyup function, I have set up my views to display the searched contacts in a template. Here is how my views are structured: def contacts_profile(request, search_id=None): contact = Invitation.o ...

Triggering a jQuery click event to showcase the hidden content

I am attempting to replicate the functionality seen on the website. The issue I am facing is related to the event_content class. I want to display only a limited amount of content initially, and then hide the excess content. Upon clicking the plus class, ...

Interactive preview of PDFs with pdf.js adaptation

How can I update my PDF preview when resizing the window? Currently, the canvas resizes but the PDF preview remains the same size. I am struggling to find a solution for this. var myState = { pdf: null, currentPage: 1, zoom ...

Revise the cascading style sheets for HTML content loaded via AJAX

I have a situation where I am dynamically loading HTML content using AJAX with JQuery. After the content is loaded, I am triggering a click event on specific elements within the newly added HTML. However, I am encountering an issue when trying to set the ...

Engaging JavaScript Navigation

I am looking to create an interactive JavaScript menu or image map where users can press down, highlight, and hit enter on four different items to reveal hidden messages. However, I struggle with JavaScript and could really use some assistance. I have alr ...