开发者

Flexigrid: window.resize problem

I managed to come up with a code that can make flexigrid more "fluid", more specifically it can resize depending on the window size on page load, but now I would like to add the function to resize automatically when the size of the window changes without refreshing it.

This is what I have so far:

$(document).ready(function(){
var myWidth;
var myHeight;
var rowno;
    if($(window).resize(function(e) {
  // do something when window resizes
    if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
    var rowno = Math.floor((myHeight - 96)/29)
  }));
    $("#flex1").flexigrid
            (
            {
            url: 'post2.php',
            dataType: 'json',
            colModel : [
                {display: 'ID', name : 'id', width : (myWidth*0.018), sortable : true, align: 'center', hide: false},
                {display: 'URL', name : 'url', width : (myWidth*0.38), sortable : false, align: 'left'},
                {display: 'File Name', name : 'filename', width : (myWidth*0.239), sortable : true, align: 'left'},
                {display: 'Availability', name : 'availability', width : (myWidth*0.038), sortable : true, align: 'center'},
                {display: 'State', name : 'state', width : (myWidth*0.029), sortable : true, align: 'center'},
                {display: 'Total Size', name : 'totalsize', width : (myWidth*0.05), sortable : false, align: 'center'},
                {display: 'Current Size', name 开发者_Python百科: 'currentsize', width : (myWidth*0.05), sortable : false, align: 'center'},
                {display: 'Procent', name : 'procent', width : (myWidth*0.04), sortable : true, align: 'center'},
                {display: 'Log',  width : (myWidth*0.018), sortable : false, align: 'center'},
                ],
            buttons : [
                {name: 'Add', bclass: 'add', onpress : test},
                {name: 'Delete', bclass: 'delete', onpress : test},
                {separator: true},
                {name: 'Start', bclass: 'start', onpress : test},
                {name: 'Stop', bclass: 'stop', onpress : test},
                {separator: true},              
                {name: 'Select All', bclass : 'selectall', onpress : test},
                {name: 'DeSelect All', bclass : 'deselectall', onpress : test},
                {separator: true}
                ],
            searchitems : [
                {display: 'URL', name : 'url'},
                {display: 'Filename', name : 'filename', isdefault: true}
                ],
            sortname: "id",
            sortorder: "asc",
            usepager: true,
            title: '',
            useRp: false,
            rp: rowno,
            showTableToggleBtn: true,
            height: (myHeight - 96)
            }
            );   
});

Right now it throws me an error in jquery about an invalid argument, but I am pretty sure is syntax problem.

Thanks,

Cristian.


if u see the height size of any element and u add it together it 120px aprox. so if u do something like this (flexigrid config object property), u'll be ok:

$("#tabla").flexigrid({
   ...,
   width:'auto',
   height:$("#container").innerHeight()-120
});


better use % for size in place of px or em it works fine without such big script

** edit **

if u still want to do give a settimeout function which will check every 1 sec the size of the browser window.height and width with window.width :)

if u succeed with this I'm the first one to copy your script I'm searching for the same . . but got used to %

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜