Crispín Klander
Crispín Klander

Reputation: 87

Datatables & Bootstrap pagination

I am using datatables & Bootstrap in a JSP page

https://datatables.net/manual/styling/bootstrap-simple.html

and I would like to add the onchange function in the selector of Show N entries

Would this be possible ??????????

this is the code in my JSP:

  <script>
            $(document).ready(function(){
                $('[data-toggle="tooltip"]').tooltip();
                var table = $('#deviceTableId').DataTable({
                    "dom": '<"top">rt<"bottom"lp><"clear">',
                    "autoWidth": false,
                    "columnDefs": [
                        {"targets": 'nosort', "orderable": false, "width": '30%'},
                        {"targets": [0], "width": '20%'},
                        {"targets": [1], "width": '35%'},
                        {"targets": [2], "width": '15%'},
                    ]
                });
                table.columns().every( function () {
                    var that = this;
                    $( 'input', this.header() ).on( 'keyup change', function () {
                        if ( that.search() !== this.value ) {
                            that
                                .search( this.value )
                                .draw();
                        }
                    } );
                } );
            });

        </script

>

Upvotes: 0

Views: 112

Answers (1)

Aneesh Sivaraman
Aneesh Sivaraman

Reputation: 931

Use this code for getting the change event.

 $(document).ready(function() {

 $('#example').DataTable();

 $(".dataTables_length label select").change(function(){
  alert(this.value);
 });

});

Refer this Fiddle

Upvotes: 1

Related Questions