php - data table grows out of container DIV -


i using jquery datatable

<div id="wrapperdiv">  <table id="datatable"> <!-- data --> </table>  <div/> 

wrapper's width 960 px , table goes 1080 px (it has broader data)

i tried

-    setting width: 100% in table tag inline css -    setting overflow-x auto; in table tag 

and promising looking solutions from

jquery datatables: control table width

how set column widths jquery datatable?

datatables width problem

jquery datatables - table width shorter datatable_wrapper width

none of them worked me, workaround increased width of wrapper div fit data table. help?

i've had same problem off , on months, none of suggested solutions fixed problem. today decided brute-force , worked. it's not elegant solution, nor it's "right" way it, works , pretty minimal in impact.

$(document).scroll(function() {             var greatestwidth = 0;             $('.datatable').each(function() {                 if (greatestwidth < $(this).width()) {                     greatestwidth = $(this).width();                 }             });              $('#yourcontainer').width(greatestwidth);         }); 

basically try find largest table (would work height well) whenever user scrolls , set container width. reason had way i'm using ajax , apis fill in data , settings table resizes few times before complete. none of datatables complete functions work due resizing , reformatting take place after-the-fact, , $(document).ready() doesn't work because table changed after document loads.

it's ugly trick.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -