Note that there are some explanatory texts on larger screens.

plurals
  1. PODatatables: Change height of table not working
    primarykey
    data
    text
    <p>I am using a Jquery Datatables table with bPaginate = false and sScrollY is some fixed height. Ultimately I want the table to resize on the window.resize event. </p> <p>To get this to work I have built a smaller testcase: In the following code snippets I want the table to resize when I click the button</p> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" language="javascript" src="http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js"&gt;&lt;/script&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;JS Bin&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;input id="button" type="button" value="Click me!" /&gt; &lt;table cellpadding="0" cellspacing="0" border="0" class="display" id="example"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Rendering engine&lt;/th&gt; &lt;th&gt;Browser&lt;/th&gt; &lt;th&gt;Platform(s)&lt;/th&gt; &lt;th&gt;Engine version&lt;/th&gt; &lt;th&gt;CSS grade&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr class="odd gradeX"&gt; &lt;td&gt;Trident&lt;/td&gt; &lt;td&gt;Internet Explorer 4.0&lt;/td&gt; &lt;td&gt;Win 95+&lt;/td&gt; &lt;td class="center"&gt; 4&lt;/td&gt; &lt;td class="center"&gt;X&lt;/td&gt; &lt;/tr&gt; &lt;tr class="even gradeC"&gt; &lt;td&gt;Trident&lt;/td&gt; &lt;td&gt;Internet Explorer 5.0&lt;/td&gt; &lt;td&gt;Win 95+&lt;/td&gt; &lt;td class="center"&gt;5&lt;/td&gt; &lt;td class="center"&gt;C&lt;/td&gt; &lt;/tr&gt; &lt;tr class="odd gradeA"&gt; &lt;td&gt;Trident&lt;/td&gt; &lt;td&gt;Internet Explorer 5.5&lt;/td&gt; &lt;td&gt;Win 95+&lt;/td&gt; &lt;td class="center"&gt;5.5&lt;/td&gt; &lt;td class="center"&gt;A&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;th&gt;Rendering engine&lt;/th&gt; &lt;th&gt;Browser&lt;/th&gt; &lt;th&gt;Platform(s)&lt;/th&gt; &lt;th&gt;Engine version&lt;/th&gt; &lt;th&gt;CSS grade&lt;/th&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Javascript:</p> <pre><code>$('#button').click(function() { console.log('Handler for .click() called.'); table = $('#example').dataTable(); settings = table.fnSettings(); console.log('old:' + settings.oScroll.sY); settings.oScroll.sY = '150px'; console.log('new:' + settings.oScroll.sY); table.fnDraw(false); }); $('#example').dataTable({ "sScrollY": "350px", "bPaginate": false, "bJQueryUI": true }); </code></pre> <p>Console output is as expected:</p> <pre><code>Handler for .click() called. old:350px new:150px </code></pre> <p>but the table doesn't update! Any idea what I am doing wrong?</p> <p>A live example can be found here: <a href="http://jsbin.com/anegiw/12/edit" rel="noreferrer">http://jsbin.com/anegiw/12/edit</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload