Home > Web Front-end > JS Tutorial > body text

Sample code for jqGrid to adapt its size as the window size changes_jquery

WBOY
Release: 2016-05-16 17:06:41
Original
1186 people have browsed it

The first type:

jqGrid adapts its width as the window size changes

Copy code The code is as follows:

$ (function(){
$(window).resize(function(){
$("#listId").setGridWidth($(window).width());
});
       });

Second type:
Copy code The code is as follows:

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};
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template