Tabulator 4.9.3运行时修改占位符触发appendChild类型错误求助
运行时动态修改Tabulator占位符触发类型错误
基本信息
- 依赖Tabulator版本:4.9.3
- 已参照Tabulator仓库中已归档的同类问题推荐方案尝试实现
- 已搭建最小可复现示例,可稳定复现报错场景
报错详情
Tabulator实例初始化阶段直接抛出以下错误:
tabulator.min.js:4 Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'. at s.redraw (tabulator.min.js:4) at e.h.redraw (tabulator.min.js:6) at ResizeObserver.<anonymous> (tabulator.min.js:12)
对表格表头应用过滤规则(例如输入过滤值为5)时,会重复触发完全一致的报错堆栈。
现有初始化代码
var data = [{id:1}, {id:2}, {id:3}]; var placeholder = $("<span>Waiting for data</span>"); var conf = { // placeholder: "Waiting for data", placeholder: placeholder, columns: [ { title: "Id", field: "id", headerFilter: "input" }, ], dataFiltered: (filters, rows) =>{ placeholder.text(filters.length > 0 ? 'No Results': 'Waiting for data'); }, }; var t = new Tabulator('#tbl', conf); setTimeout(function(){ t.setData(data)}, 5000); // timeout is just to show the initial placeholder
实际需求
实现占位符文本随表格过滤状态动态切换:
- 无生效过滤条件时,占位符显示“Waiting for data”
- 存在生效过滤条件且无匹配数据结果时,占位符显示“No Results”
内容的提问来源于stack exchange,提问作者i100
相关产品推荐
相关产品推荐

