티스토리 뷰

Development/.etc

jqGrid auto width

쥬리리리 2022. 4. 14. 10:20

jqGrid도 colModel에서 width를 %로 줄 수 있다.

shrinkToFit 를 true로 바꾸고 width도 %로 변경하면 자동으로 width가 바뀐다.

 

$grid.jqGrid({
	        url : gridUrl,
			datatype: "json",
			mtype : "GET",
	        scroll: 1,
            rownumbers: false,
	        rowNum: 30,
	        autowidth: true,
			shrinkToFit: true,  --> 중요
            height: "auto",
            postData : queryValue,
	        jsonReader : {
	        	root : "resultList",
	        	page : "currentPage",
	        	total : "totalPage",
	        	records : "totalCount"
	        },
	        colModel: [
				{ hidedlg: true, name: 'resourceType', hidden: true},
				{ hidedlg: true, name: 'storyId', hidden: true},
				{ hidedlg: false, label:'구분', name : 'icon', index: 'icon', width:'20%'},
				{ hidedlg: false, label:'제목', name: 'title', index: 'title', align: 'left', width: '80%'}
			],
setTimeout(function(){
		window.newsLayout = $(".layoutWrapper").layout({
			applyDemoStyles : true,
			maskIframesOnResize: true,
			onload_end : function(){
				if(listType == 'sediaDBResource') {
					sediaInitGrid();
				}else if(listType == "yonhapResource"){
					yonhapInitGrid();
				} else {
					<%--CMS 상세검색--%>
					initGrid();
				}
			},
			south : {
				size: 300,
				minSize: 100,
				maxSize: 450,
				resizerDblClickToggle:false,
				autoResize:false,
				closable: false,
				onresize_end :
					$.debounce(150, function(){
						console.log('dd');
						$grid.setGridHeight($("#newsGridWrapper").height() - 20);
						$grid.setGridWidth($("#newsGridWrapper").width() + 20);//얘 꼭필요
						//$grid.setGridWidth($("#newsGridWrapper").width() + 20);
						$("#newsPreview").contents().find("#right_preview").height($(".ui-layout-south").height());
					}),
			}
		});

	},400);

$grid.setGridWidth($("#newsGridWrapper").width() + 20); 가 중요

'Development > .etc' 카테고리의 다른 글

[Oracle]scott계정 비밀번호 모를 때  (0) 2022.04.22
정규식 패턴 / 유효성검사  (0) 2022.04.14
github local project upload  (0) 2022.04.08
MSA 특징, 장/단점  (0) 2022.03.29
안드로이드 크롬 디버깅  (0) 2021.11.24
댓글
링크
최근에 올라온 글
Total
Today
Yesterday