简体   繁体   中英

Find # of rows of Tabulator table

I have a table on a website that I made using Tabulator. Is there a way to get the # of rows of the table at any moment. Such as table.size or table.length?

table = new Tabulator("#example-table", { height:405,
paginationSize:50, pagination:"local", data.tabledata, columns: [...]});

Check if this helps your problem:

Javascript:

var tabulator_table = 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 el = document.getElementById("search_count");
        el.innerHTML = rows.length;
    },
    dataLoaded: function(data) {
        var el = document.getElementById("total_count");
        el.innerHTML = data.length;
    },
});

var total_count = $(".tabulator-footer").find('.tabulator-cell:first-child()').text();
$("#total_count").text(total_count);
//rest of your js if you have any.

CSS:

.tabulator-footer {
    display: none;
}

HTML:

<span style="color:#102D4F;font-size:12px;font-family:Arial, Helvetica, sans-serif">
  Showing <span id="search_count"></span> results in total <span id="total_count"></span> 
</span>

Credit: beNiceWeAlLearning

You can use the getDataCount function to get a count of all rows in the table:

var rowCount = table.getDataCount();

I have a table on a website that I made using Tabulator. Is there a way to get the # of rows of the table at any moment. Such as table.size or table.length?

table = new Tabulator("#example-table", { height:405,
paginationSize:50, pagination:"local", data:tabledata, columns: [...]});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM