简体   繁体   中英

How can i resize <div> Element with flexigrid in <div>

html data

<div id="flexdiv" class="resizable-ui">
<div> etc layer .. </div>

<table class='flexme1'>
...
</table>

</div>

jquery data

    var width = $(div).width(),
        height = $(div).height()-100;

     $('.flexme1').flexigrid({
         width: width,
         height: height,
         resizable: false,
         singleSelect: true});



$(div).resize(function() {
          var width = $(div).width(),
              height = $(div).height() -20;
          $('.flexme1').flexigrid({height:height,width:width,striped:false});
        });

it is not working i don't know what is it problem help me angles!!!!!!!!!!!!!!! plz..

So i have written the code where you can resize both div and table element:

<div id="flexdiv" class="resizable-ui" style="border: 1px solid">
<div> etc layer .. </div>

<table id="table1" class='flexme1' style="border: 2px dotted; width:200px; height:200px">
</table>

</div>

Javascript:

var div = document.getElementById("flexdiv");
var width = $(div).width(),
height = $(div).height();

alert("Div-OldHeight: "+ height);
alert("Div-OldWidth: "+ width);
var newHeight = "600px";
var newWidth = "400px";
div.style.height = newHeight;
div.style.width = newWidth;
alert("Div-NewHeight: "+ newHeight);
alert("Div-NewWidth: "+ newWidth);

var table = document.getElementById("table1");
width = $(table).width(),
height = $(table).height();

alert("Table-OldHeight: "+ height);
alert("Table-OldWidth: "+ width);
var newHeight = "100px";
var newWidth = "100px";
table.style.height = newHeight;
table.style.width = newWidth;
alert("Table-NewHeight: "+ newHeight);
alert("Table-NewWidth: "+ newWidth);

I have placed the new Width and height in variables, you can change them according to your needs, hopefully you will get the basic idea of how to do it. You can also make table dependent on the size of div, basic core will remain the same as i have provided you..

See the demo here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM