admin管理员组文章数量:1355713
I want to select all my checkbox
I have an input in header of datatables like this
<th style="width: 25%" ><input type="checkbox" name="checkall" class="select-checkall" id="checkall" value=""></th>
i use it like this to checked it but only work in the page that iam
$("#checkall").click(function(){
$(':checkbox').prop('checked', true);
});
check this fiddle /
I want to select all my checkbox
I have an input in header of datatables like this
<th style="width: 25%" ><input type="checkbox" name="checkall" class="select-checkall" id="checkall" value=""></th>
i use it like this to checked it but only work in the page that iam
$("#checkall").click(function(){
$(':checkbox').prop('checked', true);
});
check this fiddle http://jsfiddle/juxHn/46/
Share Improve this question edited Nov 10, 2015 at 11:39 Mathias Stavrou asked Nov 10, 2015 at 11:15 Mathias StavrouMathias Stavrou 8811 gold badge8 silver badges16 bronze badges 3- can you create a fiddle for this? – Anoop Joshi P Commented Nov 10, 2015 at 11:17
- stackoverflow./a/23675009/4161269 – Anik Islam Abhi Commented Nov 10, 2015 at 11:20
- i try this but not working stackoverflow./questions/23637586/… check this fiddle jsfiddle/juxHn/2 – Mathias Stavrou Commented Nov 10, 2015 at 11:34
1 Answer
Reset to default 5jQuery will not be able to find checkboxes in other pages than the current one because DataTables somehow hides them (maybe removes them from DOM?)
Please refer to DataTables API to access your table cells irrespective of which ones are currently shown or not / of which page you are on.
In your case, you could do:
// Use "DataTable" with upper "D"
oTableStaticFlow = $('#flow-table').DataTable({
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [0]
}],
});
$("#flowcheckall").click(function () {
var cells = oTableStaticFlow.column(0).nodes(), // Cells from 1st column
state = this.checked;
for (var i = 0; i < cells.length; i += 1) {
cells[i].querySelector("input[type='checkbox']").checked = state;
}
});
Demo: http://jsfiddle/juxHn/47/
本文标签: javascripthow to select all checkbox in DatatablesStack Overflow
版权声明:本文标题:javascript - how to select all checkbox in Datatables - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743977042a2570920.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论