簡體   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