繁体   English   中英

查找 Tabulator 表的行数

[英]Find # of rows of Tabulator table

我在使用 Tabulator 制作的网站上有一张表格。 有没有办法随时获取表格的行数。 例如 table.size 或 table.length?

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

检查这是否有助于解决您的问题:

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>

图片来源:beNiceWeAlLearning

您可以使用getDataCount function 获取表中所有行的计数:

var rowCount = table.getDataCount();

我在使用 Tabulator 制作的网站上有一张表格。 有没有办法随时获取表的行数。 比如table.size或者table.length?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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