Dynamic Column Placement in Tabulator with AutoColumns and AJAX Integration

Hey there, I'm currently working on incorporating the autoColumns feature in Tabulator using data retrieved via AJAX. My aim is to dynamically add column definition information based on each column's requirements, like filters, sorting, etc. Despite my attempts to include this functionality within both the pageLoaded and renderComplete callbacks, I've run into an issue where it ends up 'overwriting' the filter values entered by users when the new dataset is loaded. Is there a specific callback that would be ideal for adding this code without causing the filters to be overwritten, or would I need to read the filter values and reapply them?

Let me share an example of how I have set up the header:

var table = new Tabulator("#example-table", {
    height:"600px",
    layout:"fitColumns",
    pagination:"remote",
    paginationSize:25,
    paginationSizeSelector:[10, 25, 50, 100],
    paginationButtonCount:5, 
    ajaxSorting:true,
    ajaxFiltering:true,
    pageLoaded:function(pageno){
        //pageno - the number of the loaded page

        var columns = table.getColumnDefinitions();
        //console.log(columns);
        columns.forEach(column => {
            //console.log(column);
            column.headerFilter = "input";
        });
            table.setColumns(columns);
    },
    ajaxURL:"Pagination.php", //ajax URL
    autoColumns:true
});

Answer №1

Starting with version 4.8 of tabulator (which was released during the first weekend of September 2020), a fresh option called autoColumnsDefinitions has been introduced. This feature allows you to specify additional column definitions for auto columns

var table = new Tabulator("#example-table", {
    data:tabledata,
    autoColumns:true,
    autoColumnsDefinitions:[
        {field:"name", editor:"input"}, //add input editor for the name column
        {field:"age", headerFilter:true}, //enable header filters for the age column
    ],
});

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

When two dynamically sized divs are contained within a parent div with a maximum height, the second div should be positioned at the bottom

My outer div has a maximum height of 800px. Depending on the results of a MySQL query, there could be one or two inner divs nested within the outer div. The second inner div must always be fixed to the bottom of its parent. I know how to achieve this usin ...

Tips on locking the panel size within the modalpopupextender

Hey there, I'm facing an issue with the panel of my modalpopupextender. I have two tables inside it and I want to set a fixed size for the panel. It should remain the same regardless of whether both tables are visible or not. ...

Error encountered in Worklight 5.0.6: Form too large error occurs during Ajax request when transferring large data to data adapter

My question is similar to the one found on a developer forum (the forum is read only due to migration). Here are the details: I have an HTTP adapter that connects to external web services. The payload includes audio and images, but we're encountering ...

React and Express: Alternative content to serve besides /build during development

After initializing my React app using create-react-app, I have set up an Express server to serve the client-side React application. The structure of my project is as follows: project/ build/ server/ src/ In this setup, the Express server resides i ...

When attempting to install font-awesome with meteor npm, the module 'fontawesome'" was not found

Currently working with meteor version 1.4.1.1 which has NPM support enabled. I encountered an issue after installing the npm package "font-awesome" where the console displayed an error message stating "Uncaught Error: Cannot find module 'fontawesome&a ...

Removing the cloned element is not possible

In my grid, there is a feature where hovering over a box creates a clone of that box which is positioned directly above it (using z-index/overlay). Once the user moves the cursor away from the box, an animation should play, and at the end of it, the box sh ...

Events triggered when a Jquery checkbox is toggled between checked and unchecked

I have written some HTML code that utilizes jQuery to manage checkboxes. <tr> <td> <div class="checkbox"> <label><input type="checkbox" id="checkbox2"></label> </div> </td> & ...

Is it still considered unsafe to send a password field using the GET method and AJAX?

Is it safe to send a password field with the get method using ajax? When utilizing an html form, the password can be visible in the URL. <form method='get'> <input type"password" name="pass" /> <input type="submit" valu ...

Retrieving the first five rows from a table with data entries

My task involves working with a table named mytbl, which contains 100 rows. I need to extract only the first five rows when a user clicks on "Show Top Five." Although I attempted the following code, the alert message returned 'empty': var $upda ...

Selectize Fails to Populate Options Using Ajax

ExpressJS is the platform I am using to develop a management dashboard for a community project. Right now, my main concern is integrating a modal that allows users to add new games to a database. Although I am able to fetch data remotely, I am facing diffi ...

The JSON response appears to be jumbled when making a jQuery Ajax request

My PHP script contains the following line: echo json_encode(array('success'=>'true','userid'=>$userid, 'data' => $array)); The output is as follows: { "success": "true", "userid": "1", "data": [ { ...

Steps to transfer a JavaScript variable to a PHP session

Currently, I am in the process of retrieving the value of a checkbox and assigning it to a PHP session variable. Below is the relevant portion of the code: The checkbox: $html .= '<span><input type="checkbox" id="checkbox' ...

The issue of process.server being undefined in Nuxt.js modules is causing compatibility problems

I've been troubleshooting an issue with a Nuxt.js module that should add a plugin only if process.server is true, but for some reason it's not working as expected. I attempted to debug the problem by logging process.server using a typescript modu ...

Guide on adding a new member to Mailchimp through node.js and express

Hello, I've been delving into working with APIs, particularly the mail-chimp API. However, I've encountered a problem that has me stuck: const express=require("express"); const bodyparser=require("body-parser"); const request=require("request" ...

Display the size of the data array in VueJS once the data has been retrieved from the API

Using Vue JS, I have been attempting to retrieve data from an API. My goal is to determine the length of the array and then log it to the console using a method. However, every time I try to do this, the value logged is always "0" instead of the actual le ...

npm ERROR: Unable to install the package named "<packageName>" because it conflicts with an existing package of the same name

Currently, I am attempting to incorporate the jsonfile package into my project. However, I am encountering a couple of errors: An issue arises when attempting to install a package with the same name as another package within the same directory. (Despite ...

Different JavaScript entities with identical attributes (labels)

Even though JavaScript doesn't have tangible objects, I'm struggling to differentiate between them. Let's say we have two objects called Apple and Orange defined as follows: function Apple(){ this.name = "Apple"; } and function Orang ...

Running multiple languages locally may encounter issues, however, Codepen operates smoothly without any problems

While conducting research, I came across several options for creating multilingual websites. After implementing one method (jQuery), I noticed some slowness in translation and processing the information. Additionally, it only partially worked in the normal ...

What is the best way to send a JQuery variable using JSON.stringify and retrieve it on the server-side?

I need to pass the value in JSON.stringify and receive it on the Server side. Please note: When I attempt to pass the value directly without utilizing a JQuery variable, everything works smoothly. Without using a JQuery variable (it's functional) d ...

Accessing Ionic rootScope within the config stateprovider - A step-by-step guide

Is it possible to access the value of $rootScope in the following line? .config(function($stateProvider, $urlRouterProvider) { $stateProvider // I am trying to retrieve the value of $rootScope here. } ...