[英]How could i see all rows of my table in Dom?
我已经在表上应用了数据表,并且工作正常。 请检查CodePen的链接
$(document).ready(function() {
var table = $('#example').DataTable({
select: false,
"columnDefs": [{
className: "Name",
"targets":[0],
"visible": false,
"searchable":false
}]
});//End of create main table
$('#example tbody').on( 'click', 'tr', function () {
alert(table.row( this ).data()[0]);
} );
});
但是由于分页,它没有加载Dom中的所有行(57)。 我遇到的情况是我需要分页并且也想要dom中的所有行。 禁用分页不是一种选择。
由于您的数据表使用客户端渲染,因此您可以使用此api-> data()访问所有数据
小提琴的简单用法
var table = $('#example').DataTable({
select: false,
"columnDefs": [{
className: "Name",
"targets":[0],
"visible": false,
"searchable":false
}]
});//End of create main table
$('#example tbody').on( 'click', 'tr', function () {
alert(table.row( this ).data()[0]);
});
table.data().each(function(d){console.log(d)}) // this will print all your data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.