Tabulator总行数(列计算)也被导出

问题描述 投票:0回答:1

我正在使用这种方法来显示表中的总行数:

var tabulator_table = new Tabulator("#example", {

                        columns: [

                            { title: "name", field: "name", bottomCalc: "count", headerFilter: "input" },
                            { title: "Type", field: "Type", bottomCalc: "count", headerFilter: "input" },
                        ],
                        dataFiltered: function (filters, rows) {
                            var el = document.getElementById("search_count");
                            el.innerHTML = rows.length;
                        },
                        dataLoad: 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);


$(".tabulator-footer").append("<span class='search_count' id='search_count'></span> Of<span class='search_result'>Total Productions: <span class='total_count'></span></span>")

                    var totalsearch = $("#total_count").text();
                    var resultsearch = $("#search_count").text();
                    $(".total_count").text(totalsearch)
                    $(".search_count").text(totalsearch);
//This CSS will hide the footer:
   .tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row .tabulator-col-resize-handle {
                    display: none;
                }

这很好,但是有一个问题:当我点击导出到excel时,它也会导出计算行,例如:

  • 名称类型
  • 约翰·人类
  • 1 1

如何停止导出计数行(1 1)或是否有其他方法显示总行数。这是导出功能:

document.getElementById("myButtons").addEventListener("click", function () {
                        tabulator_table.download("xlsx", "name.xlsx", { sheetName: "Info" });
                    });
tabulator
1个回答
2
投票

我想您所需要的只是表选项中的downloadConfig选项。 http://tabulator.info/docs/4.6/download#advanced-config

因此,只需将downloadConfig: {columnCalcs: false}添加到表选项中。

这里是一个有效的例子。https://jsfiddle.net/nrayburn/0hn6v48r/11/

© www.soinside.com 2019 - 2024. All rights reserved.