我创建了一个显示条目框,但我不知道如何将其链接到数据表,因此它呈现所选的数字。我这样做是通过使用CSS和JS来固定盒子的位置,阅读它们的文档对我不是很有帮助。谢谢。 这是我的选择框代码:
我尝试过: .pageLength .lengthMenu 脚本中的.plengthMenu
<div class="fixedd" style="color: azure">
Show Entries: <select name="showentries" type="select"
id="showentries" placeholder="Search...." style=" color: black">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
这是我的脚本:
$(document).ready(function () {
var dataTable = $('#scrape').dataTable({
"pageLength": 100,
"bLengthChange": false,
});
$("#searchbox").keyup(function () {
dataTable.fnFilter(this.value);
});
$("#showentries").keyup(function () {
datatable.lengthMenu(this.value);
});
});
通过搜索框正常运行。
答案 0 :(得分:0)
这就是我所做的,以使其正常工作。但是,只有在有人对如何使其在chrome上运行有想法时,它才可以在IE上运行。
<div class=" fixedd" style="color: azure">
Show Entries: <select name="showentries" type="select" id="showentries" placeholder="Search...." style="color: black">
<option id="_10" value="10">10</option>
<option id="_25" value="25">25</option>
<option id="_50" value="50">50</option>
<option id="_100" value="100">100</option>
</select>
</div>
<script>
$(document).ready(function () {
var dataTable = $('#scrape').dataTable({
// "pageLength": 100,
"bLengthChange": false,
fixedHeader: {
header: true,
footer: true,
headerOffset: 50
},
});
var table = $('#scrape').DataTable();
$("#searchbox").keyup(function () {
dataTable.fnFilter(this.value);
});
//'.btn-details',
$("#scrape").on('click', function () {
table.page.len(10).draw();
});
$("#scrape").on('click', function () {
table.page.len(25).draw();
});
$("#scrape").on('click', function () {
table.page.len(50).draw();
});
$("#scrape").on('click', function () {
table.page.len(100).draw();
});
});
</script>