我已按照以下指南(/sf/answers/3197085391/)并排放置表格.由于输出表的高度不对称,我无法更改两个表的高度(我更喜欢增加表的显示行号,因此具有更长的表).
我的源代码,请注意我使用的是Bootstrap:
<div class="container" id="coverpage">
<div class="row">
<div class="col-md-6 col-sm-12">
<table id="tableblock" class="display"><caption><h3 style="color:black;">Latest Blocks</h3></caption></table>
</div>
<div class="col-md-6 col-sm-12">
<table id="tabletxs" class="display" ><caption><h3 style="color:black;">Latest Transactions</h3></caption></table>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,第一个表显示的行号是2.原始时它应该是5(当我注释掉时<div class="col-md-6 col-sm-12"> ).
[问]我怎样才能使两个表的总高度更大(增加要显示的行数)并使两个表对称?
感谢您宝贵的时间和帮助.
我意识到我的错误。当我增加scrollY: value 时,它解决了我的问题,该问题在 下定义$(document).ready(function())。
例子:
$(document).ready(function() {
$.get("btabl", function(result){
$('#tableblock').DataTable( {
data: result,
scrollY: 800, //I increased this value.
paging: false,
info: false,
searching: false,
order: [[ 0, "desc" ]],
columnDefs: [
{
targets: [0,1],
render: function ( data, type, row, meta ) {
if(type === 'display'){
data = " " + data ;
data = data.replace(/(@@(.+)@@)/,'<a onClick="a_onClick(' + "'" + "$2" + "'" + ')">' + "$2" + '</a>') ;
// data = '<a onClick="a_onClick(' + "'" + encodeURIComponent(data) + "'" + ')">' + data + '</a>';
// data = '<a href="search/' + encodeURIComponent(data) + '">' + data + '</a>';
}
return data;
}
},
{className: "dt-center", "targets": [0,1,2,3]}
],
columns: [
{ title: "Block" },
{ title: "Mined By" },
{ title: "Time" },
{ title: "Txs" }
]
})
})
} ) ;
Run Code Online (Sandbox Code Playgroud)