How to change default sorting order when table has print header
How to change default sorting order when table has print header
km_adusumilli
Posts: 2Questions: 2Answers: 0
I want to add this "order": [[ 1, "desc" ]] in my Code,i tried adding in $(document).ready(function() { but dint work,can you please help when i can add
<script >
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = parseInt( $('#min').val(), 10 );
var max = parseInt( $('#max').val(), 10 );
var age = parseFloat( data[15] ) || 0; // use data for the filer column
if ( ( isNaN( min ) && isNaN( max ) ) ||
( isNaN( min ) && age <= max ) ||
( min <= age && isNaN( max ) ) ||
( min <= age && age <= max ) )
{
return true;
}
return false;
}
);
$(document).ready(function() {
var table = $('#inventory').DataTable({dom: 'Bfrtip',buttons: ['print'],lengthMenu: [[ 10, 25, 50, -1 ],[ '10 rows', '25 rows', '50 rows', 'Show all' ]], buttons: ['print','excel','pageLength']} );
$('#min, #max').keyup( function() {
table.draw();
} );
} );
</script>
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin