简体   繁体   English

Web组件对制表器的支持

[英]Webcomponent support for Tabulator Table

I would like to use the very nice Tabulator ( http://tabulator.info/ ) javascript table in a webcomponent. 我想在Web组件中使用非常漂亮的Tabulator( http://tabulator.info/ )javascript表。

However it looks like the main Tabulator instance can only be created via a html selector like this: 但是,看起来主要的Tabulator实例只能通过html选择器创建,如下所示:

var table = new Tabulator("#example-table", {...});

Unfortunately looks like the #example-table is not visible in the shadowDom of webcomponents: 不幸的是,看起来#example-table在webcomponents的shadowDom中不可见:

class WcProjects extends HTMLElement {
    constructor() {
        super();
        // Attach a shadow root to the element.
        let shadowRoot = this.attachShadow({mode: 'open'});
        shadowRoot.innerHTML = `<div id="example-table"></div>`;
}
connectedCallback() {
    var table = new Tabulator("#example-table", {...});
}

Is there another way of instantiating the Tabulator table? 还有另一种实例化制表器表的方法吗?

Any help is much appreciated. 任何帮助深表感谢。

The Tabulator constructor accepts either a selector or a DOM node into the constructor element of the table, ie: Tabulator构造函数将选择器或DOM节点接受到表的构造器元素中,即:

var tableHolder = document.createElement("div");
var table = new Tabulator(tableHolder , {...});

so as long as you have access to that node, which your component should give you, you can pass that into the constructor 因此只要您有权访问组件应提供给您的那个节点,就可以将其传递给构造函数

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

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