How can I remove the pagination and show features of a jQuery Data Table ? I only want the searching and sorting features of it and want to get rid the other features. Is there any way?
问题:
回答1:
You can do it like this if you are using without jQuery UI themes
$(document).ready( function() {
$('#example').dataTable( {
"sDom": 'frt' // only show search.. processing.. and table
});
});
http://live.datatables.net/iqewoh/2/edit#preview
with jQuery UI Theme
$(document).ready( function() {
$('#example').dataTable( {
"sDom": '<"H"f>rt' // only show search.. processing.. and table
});
});
<"H"lfr>t<"F"ip> == In header put lfr
.. table .. then footer put ip
The following options are allowed:
'l' - Length changing
'f' - Filtering input
't' - The table!
'i' - Information
'p' - Pagination
'r' - pRocessing
The following constants are allowed: 'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')
'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')
The following syntax is expected: '<' and '>' - div elements
'<"class" and '>' - div with a class
'<"#id" and '>' - div with an ID
Default: lfrtip (when bJQueryUI is false) or <"H"lfr>t<"F"ip> (when bJQueryUI is true)
回答2:
The sDom
option doesn't specifically control pagination. In other words, even with sDom specified, only the first "page" of data is displayed, although all the pagination controls are hidden.
A better way to do this, at least with 1.9x version of DataTables is to specify the bPaginate
option.
$(element).dataTable({
"bPaginate": false
});
This will prevent pagination and will hide pagination controls.