当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jqGrid随窗口大小变化自适应大小的示例代码

jqGrid随窗口大小变化自适应大小的示例代码

2019年03月20日  | 移动技术网IT编程  | 我要评论

第一种:

jqgrid随窗口大小变化自适应宽度

. 代码如下:


$(function(){
            $(window).resize(function(){  
         $("#listid").setgridwidth($(window).width());
        });
       });


第二种:

. 代码如下:


window.onresize = function  _doresize() {
 var ss = pagesize();
 $("#listid").jqgrid('setgridwidth', ss.winw-10).jqgrid('setgridheight', ss.winh-200);
   }

 function pagesize() {
   var winw, winh;
  if(window.innerheight) {// all except ie
   winw = window.innerwidth;
   winh = window.innerheight;
  } else if (document.documentelement && document.documentelement.clientheight) {// ie 6 strict mode
   winw = document.documentelement.clientwidth;
   winh = document.documentelement.clientheight;
  } else if (document.body) { // other
   winw = document.body.clientwidth;
   winh = document.body.clientheight;
  }  // for small pages with total size less then the viewport
  return {winw:winw, winh:winh};

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网