gpt4 book ai didi

jQuery 数据表和标题复选框

转载 作者:行者123 更新时间:2023-12-01 07:18:47 25 4
gpt4 key购买 nike

我正在使用 jQuery 数据表,我想要一列复选框,并且标题应包含一个全选复选框。我在数据表官方网站上没有找到任何关于此的详细信息。

有人可以帮忙吗?

谢谢。

最佳答案

一种方法是使用数据表的 aoColumns 属性,并将“sTitle”属性的标记呈现为 html 字符串。

http://www.datatables.net/usage/columns

//On datatable init the options would look something like this
"aoColumns": [{ "sTitle": "<input type='checkbox' id='selectAll'></input>"}]

然后,您可以在创建数据表后将处理程序连接到标题复选框以选中/取消选中所有复选框;

所以类似:

$("#selectAll").toggle(function () { 
$("checkboxSelector", dataTable.fnGetNodes()).attr("checked", true); }
, function () {
$("checkboxSelector", dataTable.fnGetNodes()).attr("checked", false);
}
);

关于jQuery 数据表和标题复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16067313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com