我喜欢使用jQuery DataTable插件,并且想要创建这样的东西-

当任何人点击“列可见性”按钮时,他们会看到-

但我不喜欢全局搜索按钮和页面顶部(因为我已经在底部有分页)。
我只想要那个按钮。
所以,我做的是-
$(document).ready(function()
{
var dataTable = $('#employee-grid').DataTable(
{
processing: true,
serverSide: true,
//ajax: "employee-grid-data.php", // json datasource for AJAX Data
"ajax":
{
"url": "employee-grid-data.php",
//"type": 'POST',
"data": function ( d ) //Sending Custom Data for manupulating with elements out of the table
{
d.myKey = "myValue";
// d.custom = $('#myInput').val();
// etc
},
},
//"pagingType": "full_numbers", //Adding Last and First in Pagination
stateSave: true,
"language":{ //Custom Message Setting
"lengthMenu": "Display _MENU_ records per page", //Customizing menu Text
"zeroRecords": "Nothing found - sorry", //Customizing zero record text - filtered
"info": "Showing page _PAGE_ of _PAGES_", //Customizing showing record no
"infoEmpty": "No records available", //Customizing zero record message - base
"infoFiltered": "(filtered from _MAX_ total records)" //Customizing filtered message
},
"lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]], //For customizing number of data sets per page
dom: 'l<"toolbar">frtip Bfrtip', //"Bfrtip" is for column visiblity
initComplete: function() //Adding Custom button in Tools
{
$("div.toolbar").html('<button type="button" onclick="addNewEntry()">Add a New Record</button>');
},
buttons: [ //Column Visiblity Buttons
{
extend: 'colvis',
collectionLayout: 'fixed three-column',
postfixButtons: [ 'colvisRestore' ]
}
],
});
});更珍贵的是-
dom: 'l<"toolbar">frtip Bfrtip',
buttons: [ //Column Visiblity Buttons
{
extend: 'colvis',
collectionLayout: 'fixed three-column',
postfixButtons: [ 'colvisRestore' ]
}
],但我找到了这样的东西-

所以,我只想要绿色圆,而不是红圆。
我做错了什么?
发布于 2015-09-14 11:45:24
溶液
选项dom一开始可能有点混乱,但简单地说,它中的每个字母都是DataTables特性。字母的顺序也描述了它们在页面上的位置。
B -按钮,f滤波输入r -处理显示元件t表i -信息面板p分页控制还支持其他字母和HTML标记。有关更多信息,请参见dom选项和参数页面。
使用以下代码:
var dataTable = $('#employee-grid').DataTable({
// ... skipped ...
dom: 'Brtip',
buttons: [
{
extend: 'colvis',
collectionLayout: 'fixed three-column',
postfixButtons: [ 'colvisRestore' ]
}
]
});演示
有关代码和演示,请参见这个jsFiddle。
https://stackoverflow.com/questions/32563481
复制相似问题