首页 > 解决方案 > 如何将滑动切换按钮添加到制表符列中的每个单元格

问题描述

我正在尝试添加到制表符表中列中的每个单元格。我需要将 click() 函数与此滑动切换按钮相关联。如何为制表器中的列中的每个单元格添加角度切换开关?

我希望表格具有如图所示的滑动切换按钮。

标签: javascriptuitableviewuser-interfaceangular-materialtabulator

解决方案


我不使用角度,但我有自己的幻灯片切换,只使用格式化程序“html”。所以我认为您可以根据需要获取要插入的代码/对象

https://jsfiddle.net/o5whLz4j/

new Tabulator("#tabulator", {
    data:[ {
            "one": '<input id="oneone" type="checkbox" class="switch"><label id="oneonelabel" for="oneone">One</label>',
            "two": "1",
        },{
            "one": '<input id="onetwo" type="checkbox" class="switch"><label id="onetwolabel" for="onetwo">Two</label>',
            "two": "2",
        },{
            "one": '<input id="onethree" type="checkbox" class="switch"><label id="onethreelabel" for="onethree">Three</label>',
            "two": "3",
        },
    ],
    columns: [{
            title: "One",
            field: "one",
            formatter: "html",
        },
        {
            title: "Two",
            field: "two",
        },                  
    ],
});

推荐阅读