javascript - JQuery Change Property of Data Table -
hi there have data table created in jquery shown..
<html> <head> <link rel="stylesheet" href="ui/jquery-ui.min.css"> <script src="ui/external/jquery/jquery.js"></script> <script src="ui/jquery-ui.min.js"></script> <script src="datatables-1.10.7/media/js/jquery.js"></script> <script src="datatables-1.10.7/media/js/jquery.datatables.js"></script> </head> <body> <script> $(document).ready(function() { var table = $('#example').datatable( { scrolly: 300, paging: false }); var settings = table.fnsettings(); console.log(settings) }); </script> </body> </html>
i trying modify property scrolly have different value such 400. after initialisation. however, variable settings
apparently null.
thanks in advance.
the reason being returned null
value because jquery datatables can't find table.
you need define table html on page accordingly, above javascript, based on data display. needs follow following format (including <thead>
, <tbody>
tags.
<table id="example"> <thead> <tr> <th></th> </tr> </thead> <tbody> <tr> <td></td> </tr> </tbody> </table>
<script> $(document).ready(function() { var table = $('#example').datatable( { scrolly: 300, paging: false }); var settings = table.fnsettings(); alert(settings) }); </script>
demo: http://jsfiddle.net/wynrj8vh/
also, according documentation, need pass string value scrolly:
$('#example').datatable( { "scrolly": "200px" } );
Comments
Post a Comment