Determine the number of rows in the Tabulator's table

Can anyone tell me how to retrieve the number of rows in a table created using Tabulator on a website? Is there a method like table.size or table.length that I can use for this purpose?

The table has been initialized with the following code: table = new Tabulator("#example-table", { height:405, paginationSize:50,pagination:"local",data:tabledata, columns:[...]});

Answer №1

Try out this solution to solve your issue:

Javascript:

var table_widget = new Tabulator("#example", {
    columns: [
        { title: "", field: "", bottomCalc: "count", headerFilter: "input" },
        { title: "", field: "", bottomCalc: "count", headerFilter: "input" },
        { title: "", field: "", bottomCalc: "count", headerFilter: "input" },
        { title: "", field: "", bottomCalc: "count",headerFilter: "input" },
        { title: "", field: "", bottomCalc: "count", headerFilter: "input" },
        { title: "", field: "", bottomCalc: "count", headerFilter: "input" },
    ],
    dataFiltered: function(filters, rows) {
        var element = document.getElementById("search_results_count");
        element.innerHTML = rows.length;
    },
    dataLoaded: function(data) {
        var element = document.getElementById("total_results_count");
        element.innerHTML = data.length;
    },
});

var total_results = $(".tabulator-footer").find('.tabulator-cell:first-child()').text();
$("#total_results_count").text(total_results);
// additional JS code here if needed.

CSS:

.tabulator-footer {
    display: none;
}

HTML:

<span style="color:#102D4F;font-size:12px;font-family:Arial, Helvetica, sans-serif">
  Displaying <span id="search_results_count"></span> results from a total of <span id="total_results_count"></span> 
</span>

Credit: beNiceWeAlLearning

Answer №2

To retrieve the total number of rows in a table, simply utilize the getDataCount method:

var count = myTable.getDataCount();

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

c# - Convert selected items from checked listbox to JSON

Hey there! I have a checked listbox and I'm looking to add the checked items to my List and then serialize them with JSON. For example: public class Customer { public string Name { get; set; } public string Products { get; set; } } List& ...

The Mongoose function findbyIdAndRemove is currently not working properly when triggered on the client-side

I have a specific route in my app that uses the mongoose method findByIdAndRemove. Strangely, when I test this route using postman, it successfully deletes documents from my database. However, when I try to call this method from my client-side JavaScript f ...

Multiplying the values enclosed within two characters within a PHP string

Make sure to check out the EDIT section at the end. I have encountered invalid json data from an external URL that I need to parse and update the values of specific keys. My goal is to multiply the values by a constant number for a particular key (cent). ...

adjusting the font size based on the size of the screen

Hi everyone, I've encountered an issue with adjusting font sizes based on screen size. My framework is Bootstrap 3 and I'm using LESS. Here is the initial part of my LESS code: @font-size-base: 16px; @font-size-large: ceil((@fo ...

What is the process for modifying JSON attributes with JavaScript?

One JSON data set is provided below: [{ ID: '0001591', name: 'EDUARDO DE BARROS THOMÉ', class: 'EM1A', 'phone Pai': '(11) 999822922', 'email Pai': '<a href="/cdn-cgi/l/em ...

Non-functioning Tooltips on Google Charts

Currently, I am working on integrating Google Chart with ASP.NET and linking it to a SQL Server database. I have encountered an issue while attempting to customize the tool tip. Below is the Header Code: <script src="js/jquery/jquery-1.10.2.js" type=" ...

Avoid updating the input from ng-model while it is being edited

There are times when my model.field can be altered by both user input into an input field and by other functions running in the background. However, I want to handle situations where changes made by the user take precedence over modifications made by those ...

Web Browser Fails to Set Cookie during an Ajax Request

I am facing a perplexing issue. I have an AJAX call that triggers the processing of a login form and generates a cookie upon successful login. However, the web browser is failing to recognize the cookie. Upon troubleshooting, I have narrowed it down to so ...

What is the best way to swap out an HTML file with another without altering the link?

I'm working on an HTML file, which is basically a webpage. My goal is to create a functionality where clicking a button will dynamically replace the content of the page with another HTML file, complete with its own CSS, JavaScript functions, and other ...

Python JSON: NameError: name 'false' is not recognized

While attempting to json.load this dictionary extracted from a tweet on Twitter: {"created_at":"Thu Jul 10 20:02:00 +0000 2014","id":487325888950710272,"id_str":"487325888950710272","text":"\u5f81\u9678\u300c\u5de6\u8155\u306 ...

Downloading a file utilizing Selenium through the window.open method

I am having trouble extracting data from a webpage that triggers a new window to open when a link is clicked, resulting in an immediate download of a csv file. The URL format is a challenge as it involves complex javascript functions called via the onClick ...

Tips for customizing WTForm fields with unique CSS classes

I've recently put together a basic form snippet: class PostForm(FlaskForm): # for publishing a new blog post title = StringField("Title", validators=[DataRequired()]) submit = SubmitField('Post') The structure of my HT ...

Clicking the set button in Jquery mobile datebox resets the time

I am experimenting with the jquery mobile datebox (courtesy of Jtsage) to select time and date. Unfortunately, every time I reset the time by clicking the set button, I am unable to retrieve the correct time. Below are my code snippets: $.extend($.jtsag ...

Configure the IIS HttpCompression settings to compress only JSON responses, specifically those coming from asynchronous JavaScript and

I've been tinkering with the "applicationHost.config" file located in the directory "C:\Windows\System32\inetsrv\config." Everything seems to be going smoothly, but I just want to confirm something: <httpCompression directory=" ...

Enhance your web forms with jQuery Chosen's automatic formatting feature

Having trouble adding a feature to my multi-select input box using jQuery Chosen. The current functionality allows users to enter custom values not in the list. The new feature should automatically format numbers entered by users, for example: User input ...

Need help positioning this HTML iframe on my webpage?

Can anyone help me figure out how to position this HTML i-frame in a specific place on my webpage? <div style="overflow: hidden; width: 333px; height: 156px; position src="h: relative;" id="i_div"><iframe name="i_frame"http://url.com/click.php?a ...

Loading content dynamically into a div from an external or internal source can greatly enhance user experience on a website. By

As I work on my website, I am incorporating a div structure as shown below: <div class="container"> <div class="one-third column"> <a id="tab1" href="inc/tab1.html"><h2>tab1</h2></a> </div> & ...

Utilizing predicates in JSON: A guide

Currently, I am diving into iOS development and looking to implement a SearchBar along with a SearchDisplay Controller in my RootViewController. My goal is to display expressions from a JSON URL in the SearchBar. However, I'm encountering challenges w ...

I just installed Electron on my Mac using the command 'sudo npm install electron -g', but now I am encountering an error. How can I resolve this issue

When I first attempted to run the command, I encountered 'Permission Denied' errors so I added sudo before the command as suggested. Another recommendation was to install the electron folder at /usr/local/lib/node_modules, but even after reinstal ...

What is the most efficient way to dynamically alter the position of a div element within an HTML document using

In a scenario where a parent div contains multiple child divs, it is required that one particular child div named .div_object_last always stays at the end. Below is an example setup : HTML <div class="div_parent"> <div class="div_object"> ...