javascript - How do I refresh a page if a field width changes? -




i'm trying edit page on knack allows js modifications in combination css formatting. change made lock header on each page uses excel format. seems break when user changes number of rows in drop down selection or navigates next page.

i'm sure there few ways thought easiest way manage @ first row's style , refresh page if minimum width less desired length. if first entry in header not xxx amount of pixels, reload page using window.location.reload(); or similar.

here example of js:

$( document ).on ('knack-page-render.any', (function(event, view, data) {   var $table = $('#view_60 > table');   var $bodycells = $table.find('tbody tr:first').children();   var newwidths = [];   var colwidth = $bodycells.map(function(index, val) {     /* debug message*/     //console.log("index: " + index + ". value=" + $(this).width());       return $(this).width();     }).get();   var $headercells =  $table.find('thead tr').children();     //evaluate new max width   $table.find('thead tr').children().each(function(i){      var headerwidth = $(this).width();         var bodyrowwidth = colwidth[i];     var newwidth = headerwidth;     if (bodyrowwidth > newwidth){         newwidth = bodyrowwidth;                }      newwidth++;     $(this).css("min-width", newwidth + "px");     newwidths[i] = newwidth;     /* debug message*/    // console.log("cell: " + + ", header width=", headerwidth + ", bodyrowwidth=" +  bodyrowwidth + ", idealwidth=" + newwidth + " classes: " + $(this).attr('class'));       });   // set new widths everywhere   $table.find('tbody tr:first').children().each(function(i){     //console.log("setting new width " + newwidths[i]);     $(this).css("min-width", ( newwidths[i]) + "px");   }); })); 

here associated css:

#view_52 table {border-collapse: collapse;}  #view_52 thead {display:block; padding: 2px; margin: 0px;}  #view_52 tbody {display:block; overflow:auto; width 100%; margin: 0px; height:500px; padding:2px;} 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -