<style>
<!--
.zebra-striped {
background: #efefff 50% 50% repeat-x;
}
-->
</style>
<script language='javascript'><!--
$(function() {
$("#gridTable").jqGrid({
url:'userData.action',
datatype: "json",
autowidth: false,
altRows: true,
altclass: "zebra-striped",
colNames:,
colModel:,
sortname:'userId',
sortorder:'asc',
viewrecords:true,
rowNum: 20,
rowList: ,
jsonReader:{
repeatitems : false,
id: "userId",
total: "totalPageCount",
page: "pageNumber",
records: "totalRecordCount"
},
toolbar: ,
pager:"#gridPager",
rownumbers: true,
//multiselect: true,
pagerpos: "left"
}).navGrid('#gridPager',{edit:false,add:false,del:false, refresh:false, search:false});
doResize();
});
var t=document.documentElement.clientWidth;
window.onresize = function(){
if(t != document.documentElement.clientWidth){
t = document.documentElement.clientWidth;
doResize();
}
}
function doResize() {
var ss = getPageSize();
$("#gridTable").jqGrid('setGridWidth', ss.WinW-10).jqGrid('setGridHeight', ss.WinH-100);
}
function getPageSize() {
//http://www.blabla.cn/js_kb/javascript_pagesize_windowsize_scrollbar.html
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};
}
//http://www.wsria.com/archives/1147有另一种算法
--></script>
感谢!!! 不错。 我复制就能用。 哈哈。
这里有我的自适应宽度的一个解决方法: http://blog.csdn.net/fover717/article/details/8170436
:evil:
<>****