×

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

作者:Terry2017.02.15来源:Web前端之家浏览:9743评论:0
关键词:JQueryJS

第一种:

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};

您的支持是我们创作的动力!
温馨提示:本文作者系Terry ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://www.jiangweishan.com/article/svg1487088000716.html

网友评论文明上网理性发言已有0人参与

发表评论: